How to define Binary Variable?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm trying to solve an obtimization problem which includes constraints with binary variables

My question is how can i write these constraints and how can i define the binary variable in Matlab (oij) ?
Thanks so much
0 Kommentare
Antworten (2)
Walter Roberson
am 13 Dez. 2013
1 Kommentar
Walter Roberson
am 13 Dez. 2013
If you know the value of the binary variables ahead of time, then you would just go ahead and construct the constraint matrix
A = zeros(2*N, N);
B = zeros(2*N, 1);
R = 0;
for I = 1 : N
for J = I+1 : N
R = R + 1;
A(R, I) = +1;
A(R, J) = -1;
B(R) = O(I,J);
R = R + 1;
A(R, I) = -1;
A(R, J) = +1;
B(R) = ~O(I,J);
end
end
B = B .* L;
Note: your constraints appear to be inconsistent with regards to O(i,i). If O(I,I) = 1 - O(I,I) then the solution is O(I,I) = 1/2, but the O(I,I) is constrained to be 0 or 1.
ada
am 13 Dez. 2013
Bearbeitet: ada
am 13 Dez. 2013
2 Kommentare
Alan Weiss
am 16 Dez. 2013
There is currently only one solver for MINLP in MATLAB toolboxes: GA. See the documentation on integer constraints. You represent binary constraints by setting the variables to integer, and putting lower bounds of 0 and upper bounds of 1 for those variables.
Alan Weiss
MATLAB mathematical toolbox documentation
Siehe auch
Kategorien
Mehr zu Linear Programming and Mixed-Integer Linear Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!