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

genetic algorithmglobal optimizationMATLAB

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??

Best Answer

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)