I have my function fx= -0.818x1 + 0.241x2 + 4.737x3 + 0.2x4 + 0.483x5 - 0.02x6 + 0.06x7. And I have some constrains: 1. fx cant be larger than 100
2. 22=<x1=<40
3. 52=<x2=<80
4. 3.5=<x3=<5.9
5. 12=<x4=<22
6. 105=<x5=<150
7. 300=<x6=<700
8. 800=<x7=<1200
9. x4+x3=21
10. x5-x2=50
Please, show me the code of this optimization.

 採用された回答

John D'Errico
John D'Errico 2014 年 12 月 6 日

1 投票

Isn't this basically the same question you asked before? You have added a couple of equality constraints only.
I won't even bother to copy over the rest of your code from your last question. Just pass in these additional two variables now into linprog (where you previously passed in [] as placeholders when you had no equality constraints.)
Aeq = [0 0 1 1 0 0 0;0 -1 0 0 1 0 0];
beq = [21;50];

2 件のコメント

Ivan
Ivan 2014 年 12 月 6 日
man, I have some doubts of my code.
Basically linprog works for minimization. So for max, I have to invert my main function, which I did. But, do i have to invert this lines:
A = [-0.818 0.241 4.737 0.2 0.483 -0.02 0.06];
b = [100];
The question is:
[x,fval] = linprog(-f,A,b,[],[],lb,ub);
or
[x,fval] = linprog(-f,-A,-b,[],[],lb,ub);
John D'Errico
John D'Errico 2014 年 12 月 6 日
編集済み: John D'Errico 2014 年 12 月 6 日
READ THE HELP!!!!!!! I'll paste in the relevant lines...
min f'*x subject to: A*x <= b
x
You changed the sign of f, ONLY because you wanted to maximize the function, not minimize. That changes nothing else though.
However, if you pass in -A and -b, then do you think that you will actually be trying to solve the problem
-A*x <= -b
which is equivalent to
A*x >= b
It seems to me that would not be solving the problem you have posed.
READ THE HELP! THINK!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

製品

質問済み:

2014 年 12 月 6 日

編集済み:

2014 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by