Integer constrained ga generates initial population violate linear constraints
2 views (last 30 days)
Show older comments
I am using ga to solve a problem with linear constraints and integer variables. However, besides the [0 0 0] I assigned into the initial population, the rest of randomly generated ones in the initial population would ignore the constraints. Since I have only inequality linear constraints, it should have no problem to satisfy them even with integer variables. Anyone has a clue what is the problem?
Cap = 90;
Low = 60;
demand_predict = [76, 74, 78];
nvar = 3;
A = [-1, -1, -1; 2, 0, 0; 0, 2, 0; 0, 0, 2;...
-2, 0, 0; 0, -2, 0; 0, 0, -2];
b = [0; Cap-demand_predict(1); Cap-demand_predict(2); Cap-demand_predict(3);...
-Low+demand_predict(1); -Low+demand_predict(2); -Low+demand_predict(3)];
Aeq = [];
beq = [];
lb = [-10 -10 -10];
ub = [10 10 10];
nonlcon =[];
IntCon = 1:nvar;
InitialPop = [0 0 0];
objfunc = @(y)objfunc_stochastic(y, parameter1, parameter2);
options = gaoptimset('PopulationSize',5,'Generations',10,'InitialPopulation', InitialPop,'UseParallel','Always','PlotFcns',@gaplotbestf);
[y,fval,exitflag,output,population] = ga(objfunc, nvar, A, b, [], [], lb, ub, [], IntCon, options);
For example, I can see [8 6 -2] be generated, which violates the second constraint.
0 Comments
Answers (1)
Matt J
on 27 Jun 2014
Edited: Matt J
on 27 Jun 2014
For example, I can see [8 6 -2] be generated, which violates the second constraint.
Generated yes, but returned as a solution? I imagine GA gives itself the freedom to generate points that violate A*x<=b, but then discard them once it discovers that they don't satisfy the constraints.
Incidentally, the constraints A(2:end,:)<=b(2:end) are all simple bound constraints. It makes more sense to lump them in with lb, ub. If you do, I think you will find that GA does not generate points outside those bounds. In other words, it is easier for GA to confine the population evolution a priori to simple bounds. So, by giving GA better information about which constraints are bounds and which are more complicated, you help it do an appropriately narrower search.
2 Comments
Matt J
on 27 Jun 2014
Edited: Matt J
on 27 Jun 2014
since my objective function cannot be evaluated if y does not fit the constraints.
Easy enough to fix that.
I am a little bit surprised if it generate points (initially or by mutation/corssover) that violate constraints and discards them after fitness evaluation. Since it is a waste to compute fitness with those points,
You haven't said what evidence you see that this is occurring. If it is occurring, however, I would be surprised also.
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!