Matlab: Why GA algorithm does not satisfy non-linear constraint in its population creation?

2 views (last 30 days)
I am using GA toolbox of matlab for a large problem of optimization. I export the population and best individual for each generation, since my simulation is long I can keep track of my problem this way.
But in population creation, GA violates my non-linear constraint by almost 3 percent in each generation. Which is not logical and I do not know why it happens.
Does anyone know why it happens? I read that GA might not satisfy the non-linear constraint on the way, but it will satisfy it at the end. But so far my majority of population members at each generation (almost 90 percent) violate the non-linear constraint by 3 percent. This violation ratio of population was less in first generation but increases as the GA proceeds.
Just to mention that, if my equal type constraint gets violated by two percent, my objective function value will decrease proportionally, due to this, when optimization proceeds you see that majority of my individuals violate the constraint, and they get transferred to next generation since they give favorable objective function value (decrease the cost function when they get violated)
Here I am adding two functions named as optimization run and code:
function [x,fval,exitflag,output,population,score] = Optimizationcode(nvars,lb,ub,PopInitRange_Data,EliteCount_Data,InitialPopulation_Data)
%%This is an auto generated MATLAB file from Optimization Tool.
%%Start with the default options
options = gaoptimset;
%%Modify options setting
options = gaoptimset(options,'PopInitRange', PopInitRange_Data);
options = gaoptimset(options,'EliteCount', EliteCount_Data);
options = gaoptimset(options,'MigrationDirection', 'both');
options = gaoptimset(options,'InitialPopulation', InitialPopulation_Data);
options = gaoptimset(options,'SelectionFcn', @selectionremainder);
options = gaoptimset(options,'Display', 'iter');
options = gaoptimset('OutputFcns', @myoutputfcn);
[x,fval,exitflag,output,population,score] = ...
ga(@mainfunc,nvars,[],[],[],[],lb,ub,@nlinconst,[],options);
And I run the optimization by:
[x,fval,exitflag,output,population,score]=Optimizationcode(4,[-0.2 -0.2 -0.2 -0.2],...
[0.2 0.2 0.2 0.2],[-0.2 -0.2 -0.2 -0.2;0.2 0.2 0.2 0.2],...
2,[0 0 0 0]);
FYI: My non-linear constraint is an equal expression as below:
function [c,ceq] = nlinconst(x)
c = [];
ceq = [pi*(1^2+0.5*x(1)^2+0.5*x(2)^2+0.5*x(3)^2+0.5*x(4)^2)-1.1*pi*1^2];
end

Answers (1)

Alan Weiss
Alan Weiss on 2 Jun 2016
There is no optimization algorithm in MATLAB that is designed to satisfy nonlinear constraints at each iteration. For details of the ga nonlinear constraint algorithms, see the documentation.
And let me put in my usual plea to consider using patternsearch instead of ga. patternsearch is usually faster, more robust, and easier to tune than ga. If you are looking for a global minimum, and have finite bounds lb and ub on all components, start patternsearch from a variety of initial points, such as
x0 = lb + rand(size(lb)).*(ub - lb);
Also, it is quite possible that fmincon could address your problem if you set appropriate finite differences. When it applies, fmincon usually outperforms even patternsearch.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Categories

Find more on Systems of Nonlinear Equations 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!