Is there any difference if I write a constraint A=0 as the nonlinear inequality constraint or nonlinear equality constraint when use the genetic algorithm?
Show older comments
The relative code is:
if true
[x,fval]=ga(@objfun,Nvars,A,b,Aeq,beq,LB,UB,@nonlconstr,options);
[c,ceq]= nonlconstr(x);
%the function nonlconstr is written like this:
A=0;
for i=1:n
Vjzb(i)=function(x);
if Vjzb(i)>1.05
A=A+(Vjzb(i)-1.05)^2;
end
if Vjzb(i)<0.95
A=A+(Vjzb(i)-0.95)^2;
end
end
end
In my project, the Vjzb(i) need to satisfy the constraint 0.95≤Vjzb(i)≤1.05, so A should equal to 0.
My question is: In this program, is there any difference if I write this constraint as c=A or ceq=A when I use the genetic algorithm? In fact, I have tested them in MATLAB, and it seems that writing this constraint as c=A is better, but why?
Answers (0)
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!