On 4/28/2013 6:26 AM, Rita wrote:
> Hi, I am trying to work with the built-in GA function in Matlab.
>
> I am doing it like this described in the following :
> In the upper bound, some variables chosen by GA function depend on
> other variables. For instance, x1 x2 x3 x4 are my variables chosen by
> the GA and x1 x2 x3 should be smaller than x4. I set the upper and
> lower bound of x1 x2 x3 between 0 and 1 as 1 represents 100% and then
> in the objective function, set x1=x1*x4 to get the real x1 to x3.
>
> It works but x1, x2 and x3 is really sensitive when x4 changes.
>
> Is there any other ways to set the constraints of the parameters?
>
> Any comments or suggestions would be greatly appreciated.
> Thank you very much!
> Rita
You should not write this as a bound, but as a linear inequality constraint:
x(1) <= x(4)
x(2) <= x(4)
x(3) <= x(4)
This becomes
x(1) - x(4) <= 0
x(2) - x(4) <= 0
x(3) - x(4) <= 0
In matrix form (the form toolbox solvers want):
A*x <= b
where
A = [1,0,0,-1;
0,1,0,-1;
0,0,1,-1];
b = [0;0;0];
For more info, see
http://www.mathworks.com/help/optim/ug/writing-constraints.html#brhkghv-14
Alan Weiss
MATLAB mathematical toolbox documentation
> Hi, I am trying to work with the built-in GA function in Matlab.
>
> I am doing it like this described in the following :
> In the upper bound, some variables chosen by GA function depend on
> other variables. For instance, x1 x2 x3 x4 are my variables chosen by
> the GA and x1 x2 x3 should be smaller than x4. I set the upper and
> lower bound of x1 x2 x3 between 0 and 1 as 1 represents 100% and then
> in the objective function, set x1=x1*x4 to get the real x1 to x3.
>
> It works but x1, x2 and x3 is really sensitive when x4 changes.
>
> Is there any other ways to set the constraints of the parameters?
>
> Any comments or suggestions would be greatly appreciated.
> Thank you very much!
> Rita
You should not write this as a bound, but as a linear inequality constraint:
x(1) <= x(4)
x(2) <= x(4)
x(3) <= x(4)
This becomes
x(1) - x(4) <= 0
x(2) - x(4) <= 0
x(3) - x(4) <= 0
In matrix form (the form toolbox solvers want):
A*x <= b
where
A = [1,0,0,-1;
0,1,0,-1;
0,0,1,-1];
b = [0;0;0];
For more info, see
http://www.mathworks.com/help/optim/ug/writing-constraints.html#brhkghv-14
Alan Weiss
MATLAB mathematical toolbox documentation