Linear Programming Lecture Notes - Penn State Personal Web Server
Linear Programming Lecture Notes - Penn State Personal Web Server
Linear Programming Lecture Notes - Penn State Personal Web Server
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
11. Solving <strong>Linear</strong> Programs with Matlab<br />
In this section, we’ll show how to solve <strong>Linear</strong> Programs using Matlab. Matlab assumes<br />
that all linear programs are input in the following form:<br />
⎧<br />
min z(x) =c T x<br />
(3.56)<br />
⎪⎨<br />
⎪⎩<br />
s.t. Ax ≤ b<br />
Hx = r<br />
x ≥ l<br />
x ≤ u<br />
Here c ∈ R n×1 , so there are n variables in the vector x, A ∈ R m×n , b ∈ R m×1 , H ∈ R l×n<br />
and r ∈ R l×1 . The vectors l and u are lower and upper bounds respectively on the decision<br />
variables in the vector x.<br />
The Matlab command for solving linear programs is linprog and it takes the parameters:<br />
(1) c,<br />
(2) A,<br />
(3) b,<br />
(4) H,<br />
(5) r,<br />
(6) l,<br />
(7) u<br />
If there are no inequality constraints, then we set A = [] and b = [] in Matlab; i.e., A and<br />
b are set as the empty matrices. A similar requirement holds on H and r if there are no<br />
equality constraints. If some decision variables have lower bounds and others don’t, the term<br />
-inf can be used to set a lower bound at −∞ (in l). Similarly, the term inf can be used if<br />
the upper bound on a variable (in u) is infinity. The easiest way to understand how to use<br />
Matlab is to use it on an example.<br />
Example 3.49. Suppose I wish to design a diet consisting of Raman noodles and ice<br />
cream. I’m interested in spending as little money as possible but I want to ensure that I eat<br />
at least 1200 calories per day and that I get at least 20 grams of protein per day. Assume that<br />
each serving of Raman costs $1 and contains 100 calories and 2 grams of protein. Assume<br />
that each serving of ice cream costs $1.50 and contains 200 calories and 3 grams of protein.<br />
We can construct a linear programming problem out of this scenario. Let x1 be the<br />
amount of Raman we consume and let x2 be the amount of ice cream we consume. Our<br />
objective function is our cost:<br />
(3.57) x1 + 1.5x2<br />
Our constraints describe our protein requirements:<br />
(3.58) 2x1 + 3x2 ≥ 20<br />
and our calorie requirements (expressed in terms of 100’s of calories):<br />
(3.59) x1 + 2x2 ≥ 12<br />
47