Linear Optimization: Mixed Constraint Equation Question

조회 수: 2 (최근 30일)
Brian
Brian 2012년 9월 23일
Hello, all, thanks for reading this.
I have a question about a simple linear optimization problem. I am running a example I found online, so I can compare this to GAMS, and I am unsure on how to use these constraint equations:
% Governing Equation
% Maximize Z = x1+5x2
%
% Constraint Equations:
% x1 + 3x2 <= 5;
% 2x1 + x2 = 4;
% x1 - 2x2 >= 1;
% x1,x2 >= 0;
I know from earleir examples I would use the code:
f = [-1; -5;]; % negative b/c linprog minimization
A = [1 3;
? ?;
-1 2];
b = [5; ?; -1];
options = optimset('LargeScale', 'off');
xsol = linprog(f,A,b,[],[],[],[],[],options)
However, since I have one equality constraint, I have 1 DOF and I am not sure how to translate this to MATLAB. Would I leave the equality constraint out of the equation and linprog?
Thanks for your advice. I am unsure how to apply equality constraints in this type of problem.

채택된 답변

Rodrigo
Rodrigo 2012년 9월 24일
This can be done by hand, but assuming this is a template for a more complicated problem, you would need to use Aeq and beq to handle the equalities. The last pair of conditions require lb and ub.
f = [-1; -5;]; % negative b/c linprog minimization A = [1, 3;-1, 2]; b = [5; -1]; Aeq=[2,1]; beq=4; lb=[0;0]; ub=[Inf;Inf]; xsol = linprog(f,A,b,Aeq,beq,lb,ub);
  댓글 수: 1
Brian
Brian 2012년 9월 26일
Yes, thank you for your help! I checked some more documentation online, and I had problems with understanding the linprog function itself. I should have looked online more before I posted.
Thanks for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by