ga (genetic algorithm) violated linear constraints

1 visualización (últimos 30 días)
Chi So
Chi So el 7 de Dic. de 2020
Respondida: Alan Weiss el 7 de Dic. de 2020
Hi,
I created a simulation based optimization problem, but I kept getting a sulotion that violated the linear constraints. I cannnot copy and paste the entire code becasue there are way too many lines. Therefore, I created a function func to replace the simulation I have :
A = [-1 1 0 0 0 0 0 0;0 0 -1 1 0 0 0 0; 0 0 0 0 -1 1 0 0; 0 0 0 0 0 0 -1 1];
b = [0;0;0;0];
LB = [1e-9 1e-9 0.6 0.6 1e-9 1e-9 0.5 0.5];
UB = [1e-7 1e-7 0.8 0.8 1e-7 1e-7 1 1];
global xvar yscore
xvar = [];
yscore= [];
func=@(x) x(1)/x(2)*x(3) + x(5)/x(6)*x(4)-x(1)/x(6)*x(7)+x(2)/x(5)*x(8);
options = optimoptions('ga','ConstraintTolerance',1e-13,'OutputFcn',@gaoutfun,'PlotFcn', @gaplotbestf,'UseParallel',true,'CrossoverFcn',{@crossoverintermediate, 1},'CrossoverFraction',0.2,'MutationFcn','mutationadaptfeasible')
[x,fval,exitflag,output,population,scores] = ga(func,8,A,b,[],[],LB,UB,[],[],options);
function [state,options,optchanged] = gaoutfun(options,state,flag)
global xvar yscore
xvar = [xvar; state.Population];
yscore = [yscore; state.Score];
optchanged = false;
end
In this example, I was able to get the solution correctly. However, whenI checked xvar, I notoiced there are some populations violate the linear constraints. I'm thinking if they will also lead to a soultion violates the linear constraints because I also saw them in my orignial optimization problem.

Respuestas (1)

Alan Weiss
Alan Weiss el 7 de Dic. de 2020
I would rescale the problem first. Your x(1), x(2), x(5), and x(6) variables should be multiplied by 1e8 or 1e9, so that they have the range 1/10 to 10 or 1 to 100 instead of 1e-9 to 1e-7. You can scale them back down inside your fitness function.
Alan Weiss
MATLAB mathematical toolbox documentation

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by