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 Exchange에서 Linear 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