Linear Programming Objective Function with constant term.

조회 수: 4 (최근 30일)
Patty
Patty 2014년 4월 19일
댓글: Matt J 2014년 4월 19일
Hi,
I'm wondering how you represent a constant value in the LP formulation in MATLAB, using "linprog".
For example,
Min Z = 2 x1 + 3 x2 + 4 y
x1 and x2 are variables.
y is an input value, not a variable.
How to represent this in the coding?
thanks!

채택된 답변

Matt J
Matt J 2014년 4월 19일
편집: Matt J 2014년 4월 19일
You cannot add a constant, but there shouldn't be any need to. Adding a constant to the objective function does not change the location(s) of the solutions, x.
  댓글 수: 2
Patty
Patty 2014년 4월 19일
Thanks, I wasn't sure.
I guess I should sum the final term to the total solution after run the linprog.
Matt J
Matt J 2014년 4월 19일
Yes. One other thing you could do (although it would be silly) is to include the constant as an additional unknown x(i) in the problem, but set lb(i)=ub(i)=constant. For example, the following
[x,f]=linprog([1 1 1],[],[],[],[],[0,0,2],[inf inf 2]);
x=x(1:2);
is equivalent to
Min x(1) + x(2) + 2
s.t. 0<=x(i)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by