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

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!

 採用された回答

Alan Weiss
Alan Weiss 2014 年 12 月 11 日
編集済み: Alan Weiss 2014 年 12 月 11 日
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

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2014 年 12 月 11 日
The ga solver may not generate points that are feasible with regard to the nonlinear constraints. This doc page explains how it works:

4 件のコメント

John D'Errico
John D'Errico 2014 年 12 月 11 日
編集済み: John D'Errico 2014 年 12 月 11 日
There is NO assurance that a starting point for an optimization can be found trivially. In fact, just finding a valid starting point may require an optimization itself.
Sabrina Langer
Sabrina Langer 2014 年 12 月 12 日
編集済み: Sabrina Langer 2014 年 12 月 12 日
This is my matlab code for calling the ga
clear all
N=57;
lb = zeros(N,1);
ub = [1 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10 1E+10];
opts = gaoptimset('TolFun', 1e-8, ...
'PopulationSize', 100, ...
'Generations', 570, ...
'PlotFcns', @gaplotbestf,...
'UseParallel', true, ...
'MutationFcn',@mutationadaptfeasible)
rng(0, 'twister');
[x,fval,exitflag] = ga(@myfun, N, [], [], [], [], ...
lb, ub, @mycon, opts);
Sabrina Langer
Sabrina Langer 2014 年 12 月 12 日
編集済み: Sabrina Langer 2014 年 12 月 12 日
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 2014 年 12 月 12 日
編集済み: Sabrina Langer 2014 年 12 月 12 日
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

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 12 月 11 日

編集済み:

2014 年 12 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by