How to set upper bounds for linear programming?
18 views (last 30 days)
Show older comments
Hi,
I am trying to solve a problem using linear programming, that is maximize something. This problem has upper and lower bounds. The lower bounds are all zero, but the upper bounds differ.
I've tried to follow and do as they do in this guide: GUIDE. The problem with that is that I get the following error message: Warning: Length of upper bounds is > length(x); ignoring extra bounds. When I did this, I was using the linprog solver.
So, I have set up my program as following:
I want to maximize Z
Z = 4P1 + 3P2 + 2P3 + 2P4 + P5
A = [2 0 0 0 0; 0 2 2 2 1; 0.2 1 0 0.5 0]
f = [-40000; -30000; -20000; -20000; -10000];
b = [36000; 216000; 18000];
lb = zeros(5,1);
Now, I want to use an upper bound as well. The upper bounds look like this:
P1 <=16000, P3 <= 2000, P1+P2+P3 <= 34000, P4+P5 <= 28000
All P1-P5 are greater than, or equal to zero.
How should I formulate the upper bound?
Thanks in advance.
0 Comments
Answers (1)
John D'Errico
on 7 May 2016
These are NOT upper bounds.
P1+P2+P3 <= 34000, P4+P5 <= 28000
They are linear inequality constraints. A linear inequality constraint acts on a linear combination of the unknowns.
These are upper bounds.
P1 <=16000, P3 <= 2000,
As you see, a bound constraint acts on ONE variable, limiting that single variable from below or above. Otherwise, you could argue that ALL inequality constraints were bound constraints.
0 Comments
See Also
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!