how to code binary integer programming model?
11 ビュー (過去 30 日間)
古いコメントを表示
How can I write the matlab code for this binary integer pogramming model to find the optimal solution Z, and binary values of integer variables yi, xj :
Max Z= 23y1 + 25y2 + 54y3 + 74y4 + 13y5 + 33y6 + 47y7 + 92y8 + 17y9 + 39y10
Subject to:
0 ≥ y1
x1 ≥ y2
x1 + x6 ≥ y3
x6 ≥ y4
0 ≥ y5
x7 ≥ y6
0 ≥ y7
0 ≥ y8
0 ≥ y9
x4 ≥ y10
x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 ≤ 1
yi ∈ {0,1} , i = 1,2,.....,10
xj ∈ {0,1} , j = 1,2,.....,8
2 件のコメント
Ive J
2022 年 1 月 29 日
Don't forget your objective func needs a minus sign
f = -[23, 25, 54, 74, 13, 33, 47, 92, 17, 39];
Also for simplicity name all your variables y1 to y18, where x1 to x8 are y11 to y18.
採用された回答
John D'Errico
2022 年 1 月 29 日
編集済み: John D'Errico
2022 年 1 月 29 日
So you have 18 unknowns. What is the problem? What have you tried? You will call intlinprog, (older releases will call bintprog, which no longer exists in MATLAB) but still this is just a direct call tp intlinprog.
Learn to use indexing, and vectors, and arrays. Learn NOT to write numbered variables as you seem to be doing.
As I said, you have 18 unknowns, thus a vector of length 18 will be the result. I'll call it X. Think of the vector x as unknowns X(11) through X(18), and y is now X(1) through X(10). So the constraint x7 ≥ y6, becomes X(17) >= X(6).
Now using intlinprog, specify that ALL of the 18 unknowns are integer, with lower bounds of 0, and upper bounds of 1. That tells intlinprog this is a binary integer program.
When your call to intlinprog returns a result, then unpack the vector X into sub-vectors x and y as:
y = X(1:10);
x = X(11:18);
So read the help for intlinprog. If necessary, look at the examples provided with doc intlinporog.
help intlinprog
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!