How to set up non-linear relative constraints in Geneti Algorithm optimization

I am trying to sove an optimization problem consisting of four variables using 'ga'. The system consists of non-linear transcendental equations. My constraints for the unknown variables are like this :
0<=x(1)<=x(2)<=x(3)<=x(4)<=pi/2
The problem with the lower/upper bounds is that the lower bound exists only for x(1) and upper one exists only for x(4). The bounds for other variables are relative and matlab does not accept LB=[0 x(1) x(2) x(3)] format.
I have tried the non-linear constrainsts as well (since there are other constraints involving the cosines of unknown variables) but the results do not make any sense.
Any worthy member has any idea to circumvent this issue??

 Akzeptierte Antwort

Matt J
Matt J am 7 Okt. 2013
Bearbeitet: Matt J am 7 Okt. 2013
The constraints x(1)<=x(2)<=x(3)<=x(4) are linear constraints . They are equivalent to
x(1)-x(2)<=0
x(2)-x(3)<=0
x(3)-x(4)<=0
You need to express these using the A,b input arguments. Your code should like something like the following,
A=[1 -1 0 0; 0 1 -1 0; 0 0 1 -1];
b=[0;0;0]
LB=[0;0;0;0];
UB(1:4)=pi/2;
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB)

Weitere Antworten (1)

Alan Weiss
Alan Weiss am 7 Okt. 2013
Bearbeitet: Alan Weiss am 7 Okt. 2013
To get these linear constraints into the solver, use linear inequality constraint matrices. The constraints are:
x(1) <= x(2)
x(2) <= x(3)
x(3) <= x(4)
To put these in the form Ax <= b, take the following:
A = [1,-1,0,0;
0,1,-1,0;
0,0,1,-1];
b = zeros(3,1);
The bounds x(1) >= 0 and x(4) <= pi/2 are:
lb = [0,-Inf,-Inf,-Inf];
ub = [Inf,Inf,Inf,pi/2];
It is probably even more efficient to take
lb = zeros(4,1);
ub = pi/2 + lb;
I hope this is clear.
Alan Weiss
MATLAB mathematical toolbox documentation

4 Kommentare

Thank you both Alan and Matt ... Unfortunately, the algorithm returns with the message "Optimization terminated: no feasible point found."
let me elaborate my problem a little.. I have non-linear constraints of the form:
cos(5x(1))+cos(5x(2))+cos(5x(3))-L1<=0
cos(7x(1))+cos(7x(2))+cos(7x(3))-L2<=0
cos(11x(1))+cos(11x(2))+cos(11x(3))-L3<=0
...
...
...
so, I set up a non-lnear fucntion handle that returns 'c' and 'ceq' having the values as under:
function [c,ceq] = constraints (x)
c(1)=cos(5x(1))+cos(5x(2))+cos(5x(3))-L1;
c(2)=cos(7x(1))+cos(7x(2))+cos(7x(3))-L2;
c(3)=cos(11x(1))+cos(11x(2))+cos(11x(3))-L3;
...
...
...
ceq = [];
L1, L2, L3 ... are constants and the vectors 'A' and 'b' are as you indicated. The main optimization equation is:
fun = @(x) cos(x(1))+cos(x(2))+cos(x(3))-K
Finally, the statment
ga(fun,3,A,b,[],[],lb,ub,@constraints )
should yield atleast some result. but the algorithm stops with the message that no feasible solution found.
Could you (Alan and Matt) or some other worthy member hint to whats is wrong here??
Matt J
Matt J am 8 Okt. 2013
Bearbeitet: Matt J am 8 Okt. 2013
I'm not sure why we're to think the problem has to be feasible, but show us the values of L1, L2, L3.
Also why do you have nvars=3 when in your initial post, you mentioned 4 variables x(1)..x(4)?
My first message was generic having four variables..now I am refering to the problem that I am actually trying to solve..
The values of L1=0.05, L2=0.04 and L3=0.03.. There are in fact 16 such non-linear constraints involving cosines. The difference is only in the cosine angle multiplier. So in the first constrain, its 5, in the second it is 7, in the third it is 11. The angle multipliers continue like 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47 and 49.... For each constraint, the value of L is different .. In this case L = [5 4 3 2.5 1.6 1.2 1.2 1.2 0.63 0.6 0.56 0.54 0.5 0.49 0.47 0.46]/100 ..
In my opinion, the problem should have an optimal or 'close to optimal' solution as it represents an actual physical working system ...
Matt J
Matt J am 9 Okt. 2013
Bearbeitet: Matt J am 9 Okt. 2013
If you have a physical example of the system, then you should be able to choose at least a feasible set of design variables x(1), x(2), x(3). Plug them into your constraint function and check that c(x)<=0. Similarly check that A*x<=b and that the bounds are satisfied. If not all constraints are satisfied, you know that you've coded the equations incorrectly. If they are satisfied, then you can use that as your initial guess x0 and fmincon can't have any excuses that it can't find a feasible point.

Melden Sie sich an, um zu kommentieren.

Produkte

Gefragt:

am 7 Okt. 2013

Kommentiert:

am 9 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by