Genetic Algorithms---Mixed Integer Optimization problem with binary variables

Hello all, I have to solve the following problem today, I solved a nonlinear GA problem with my own code in VBA but this one requires a bit more time and so I wanted to try MATLAB which I am very new to it,
3X1+2X2+6X3≤150 **
4X1+3X2+4X3≤160 **
X1≤MY1 **
X2≤MY2 **
X3≤MY3 **
X1,X2,X3 ≥ 0 and integer, Y1,Y2,Y3= binary **
MAX Z=6X1+4X2+7X3–200Y1–150Y2–100Y3 **
I wrote the floowing code in MATLAB for my problem.
Fun=@(x) 6*x(1)+4*x(2)+7*x(3)-200*x(4)-150*x(5)-100*x(6);
A=[ 3 2 6 0 0 0; 4 3 4 0 0 0; 1 0 0 -1000 0 0; 0 1 0 0 -1000 0; 0 0 1 0 0 -1000];
b=[150 160 0 0 0];
lb=[ 0 0 0 0 0 0];
ub=[Inf Inf Inf 1 1 1];
[x,fval,exitflag] = ga(Fun,6,A,b,[],[], lb,ub,[], [1 2 3 4 5 6],opts);
Now it constantly returns errors first it said tenth argument is false, now it says opts is not defined, before these errors it said too many arguments for ga I don't know what to do please help Sincerely, Arda

Answers (1)

I suspect your version of MATLAB is older than R2011b, when mixed-integer GA was released.
If your version is R2011b or later, then perhaps your options structure opts is invalid somehow. You did not give code for constructing opts.
When I ran your code using exactly what you wrote, but no opts, here is what I saw:
Fun=@(x) 6*x(1)+4*x(2)+7*x(3)-200*x(4)-150*x(5)-100*x(6);
A=[ 3 2 6 0 0 0; 4 3 4 0 0 0; 1 0 0 -1000 0 0; 0 1 0 0 -1000 0; 0 0 1 0 0 -1000];
b=[150 160 0 0 0];
lb=[ 0 0 0 0 0 0];
ub=[Inf Inf Inf 1 1 1];
[x,fval,exitflag] = ga(Fun,6,A,b,[],[], lb,ub,[], [1 2 3 4 5 6])
Optimization terminated: average change in the penalty fitness value less than options.TolFun
and constraint violation is less than options.TolCon.
x =
0 0 0 1 0 0
fval =
-200
exitflag =
1
Alan Weiss
MATLAB mathematical toolbox documentation

Asked:

on 11 Nov 2012

Community Treasure Hunt

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

Start Hunting!