The Starting Point (Vector) generated by Genetic Algorithm doesn't satisfy the nonlinear constraint, why?

1 view (last 30 days)
Identification of 57 unknow parameter: (I'm using Matlab R2014a)
I have two series of measurement Gm and Vm as a function of wm . Both functions are characterised by the same 57 unknow parameter.
I want to generate a good starting vector with the 57 unknow parameter so that the sum of squares logarithmic
f= sum((log(G(wm))-log(Gm)).^2+10*(log(V(wm))-log(Vm)).^2);
becomes minimal.
-
  • There are specific bounds for the parameters
Ginf= x(1); %[0;1]
gi= [x(2:(length(x)-1)/2 +1)]; %[0;1]
taui = [x((length(x)-1)/2 +2:length(x))]; %[0,1E+10]
G0= [Ginf/(1-sum(gi))]; %[in this case >922,15]
-
  • And the nonlinear constraint mycon is (what is really important otherwise the G0 is getting negativ)
sum(gi)<1
-
-
My problem is that the nonlinear constraint isn't always statisfied . I tried to change the bounds, so that the sum(gi)is smaller than 1 and I also tried sum(gi)<0.25, but still I'm getting a lot of G0 s, which are negativ. In addition the GA isn't working really efficiently.
-
Also I was wondering about:
- rng(0, 'twister'); the reproducibility. How it works with entering there another number than 0?
- What are good settings for the options of the GA - TolFun, PopulationSize, Generations, ...?
-
See attached the matlab files with the code.
-
I never have programmed a GA, so it would be really great if somebody can help me with this problem. Thank you!

Accepted Answer

Alan Weiss
Alan Weiss on 11 Dec 2014
Edited: Alan Weiss on 11 Dec 2014
You might have better luck by turning your nonlinear constraint into a linear constraint. The constraint
sum(gi) <= 1
is a linear inequality constraint in the parlance of MATLAB solvers. I am assuming that the gi are decision variables, the ones you called Gm. For linear inequality constraints, ga is a strictly feasible solver, meaning it generates only feasible points. But it does regard its inequalities as not being strict, so you might want to make the inequality
sum(gi) <= 1-ep
where ep is a small number such as 1e-6.
Also, make sure to place bounds on your variables as a vector. If all the variables are supposed to be positive, use
lb = zeros(57,1);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (1)

Sean de Wolski
Sean de Wolski on 11 Dec 2014
The ga solver may not generate points that are feasible with regard to the nonlinear constraints. This doc page explains how it works:
  4 Comments
Sabrina Langer
Sabrina Langer on 12 Dec 2014
Edited: Sabrina Langer on 12 Dec 2014
and my nonlinear constraint is:
function [ c, ceq ] = mycon(x)
c = [x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10)+x(11)+x(12)+x(13)+x(14)+x(15)+x(16)+x(17)+x(18)+x(19)+x(20)+x(21)+x(22)+x(23)+x(24)+x(25)+x(26)+x(27)+x(28)+x(29)-1]
ceq = [];
end
Sabrina Langer
Sabrina Langer on 12 Dec 2014
Edited: Sabrina Langer on 12 Dec 2014
my function which should be optimized:
function f=myfun(x)
Mdat=xlsread('13Parameter-Gsp-und-Gver-5WerteproDekade');
syms w;
Ginf= x(1)
gi= [x(2:(length(x)-1)/2 +1)]
taui = [x((length(x)-1)/2 +2:length(x))]
G0= [Ginf/(1-sum(gi))]
G(w)=Ginf + G0*sum(gi.*(taui.^2).*(w.^2)./(1+(taui.^2).*(w.^2)));
V(w)=G0*sum(gi.*taui.*w./(1+(taui.^2).*(w.^2)));
wm=[Mdat(:,1)];
Gm=[Mdat(:,3)];
Vm=[Mdat(:,5)];
f= sum((log(G(wm))-log(Gm)).^2+10*(log(V(wm))-log(Vm)).^2);
f=double(f)
end

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!