GA with constraints not running simulation for first 4 generations
Show older comments
I'm using a GA to run some simulations and optimize parameters. I have a few constraints between parameters (or else the simulation may not run). With the constraints in place, the GA immediately jumps to the fifth generation before running the simulation. The simulations take a few minutes, so it's obvious it hasn't run until the 5th generation, at which everything behaves as expected. Screenshot below (I stopped it prematurely at 13 generations).

A = [1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;...
0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0;...
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1];
b = [4; 3; 0];
% Set Options for Optimization
options = gaoptimset('CrossoverFrac',0.5,'PopulationSize',20,...
'StallGen',12,'Generations',40,...
'PlotFcns',@gaplotbestf,'OutputFcn',@myoutputfcn);%More options can be assigned %was pop size 15, generations 25 stallgen 5
[xOpt,fVal,exitflag,output,population,scores] = ga(@(x)objective(x, Wx1, Wx2, Wz1, Wz2, LFx, LFz, LFd, LFh, RFx, RFz, RFd, RFh, OHx, OHz, OHd, OHw, OHgap),...
17,A,b,[],[],lb,ub,[],intCon,options);
Answers (0)
Categories
Find more on Particle Swarm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!