Genetic Algorithms problem with StepSize in mutationadaptfeasible function

1 view (last 30 days)
Hi all, I'm working with GAs in optimtool. When I use it, during second iteration I received problem in mutationadaptfeasible function. In fact in every step it initialites StepSize = [] and after the second iteration it remains equal to []. So it crashes because I have 2 bounds. I modify the script in this way:
persistent StepSize
..
if state.Generation <=2
StepSize = 1; % Initialization
else
if isfield(state,'Spread')
if state.Spread(end) > state.Spread(end-1)
StepSize = min(1,StepSize*4);
else
StepSize = max(sqrt(eps),StepSize/4);
end
else
if state.Best(end) < state.Best(end-1)
StepSize = min(1,StepSize*4);
else
StepSize = max(sqrt(eps),StepSize/4);
end
end
end
if(sum(size(StepSize))==0) <--- THIS
StepSize = 1;
end
...
case 'boundconstraints'
[Basis,TangentCone] = boxdirections(true,StepSize,x,linCon.lb,linCon.ub,tol); % NOW OK
Could be ok? Thanks to all

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!