A genetic algorithm code with constraints on individuals
3 views (last 30 days)
Hi all, I hope you all be in good health and doing well.
I developed a code for minimizing a multi-valued function F(x1,x2,...,x7)
the first solution set (or individual in terms of GA): x=[0.8,-0.001,0.001,0.0,0.2,-0.005,-0.0005]; and the suggested range is limited to a ratio of the initial solution: R(xi)= 0.2*xi.
I tried the ga, the results was at first few points convergent, giving descending curve, but the next was divergent, the curve was steady.
Finally, I performed that well using fminsearch in a short time. but I guess that I've been in a local minimum trapp, so, I want to write a mixed algorithm of fminsearch for local search and ga to move the solution out the local.
I suggest that my problem with ga is the need for constrains on the individual itself as shown above.
So, I need any optimization technique, favourably ga, with the availability to put constrains on the individuals in all generations with range =0.2 of each individual component.
Alan Weiss on 23 Dec 2021
I cannot understand much of what you say, but it sounds as if you are trying to give bounds on the solution. If I understand you (which I might not), you have an initial point
x0 = [0.8,-0.001,0.001,0.0,0.2,-0.005,-0.0005];
and you want to limit your population to +-20% from this initial point. So give bounds. Take into account the signs of the x0 entries:
posx0 = x0 > 0;
negx0 = x0 < 0;
lb = zeros(size(x0));
ub = lb;
lb(posx0) = 0.8*x0(posx0);
lb(negx0) = 1.2*x0(negx0);
ub(posx0) = 1.2*x0(posx0);
ub(negx0) = 0.8*x0(negx0);
Notice that lb(4) = ub(4) = 0, meaning x(4) = 0 for any solution point x.
MATLAB mathematical toolbox documentation