How to define Binary Variable?

10 ビュー (過去 30 日間)
ada
ada 2013 年 12 月 13 日
コメント済み: ate kasa 2020 年 8 月 16 日
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

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 12 月 13 日
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 12 月 13 日
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
ada 2013 年 12 月 13 日
編集済み: ada 2013 年 12 月 13 日
Thanks for your answer but the problem is what i'm trying to optimize is not depending on the binary variable oij. It's added in the constraints just to partition the problem into convex sets. So this is not a binary integer programing. It's a mixed integer nonlinear programming which includes a binary variable in the constraints.
  2 件のコメント
Alan Weiss
Alan Weiss 2013 年 12 月 16 日
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
ate kasa
ate kasa 2020 年 8 月 16 日
Dear this best help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by