How to use linprog only once for two different constraints

2 views (last 30 days)
Hello everyone.
I need help with the following problem:
I want to use the linprog function only once when I have two different constraints (actually they are equalities) for the same variable.
In one case, I have: b = [0;0;15] and in the other case I have b = [0;0;16];
You can think of it as an optimization problem that in a certain month I will produce 15 elements and 16 on next one.
I think it should be very simple, but I can't think of a way to do it.
Oh, and for the record, I know it would be super easy to just use linprog twice. The problem is I can only use it once.
With my methods I could only get unfeasible results.
Any thoughts?

Accepted Answer

Alan Weiss
Alan Weiss on 27 Aug 2014
You can make your problem twice as big. Use twice as many variables x, twice as many variables in the lb and ub bounds, and twice as many in the linear constraints. You new b will be [0;0;15;0;0;16]. Read out the answers as the first half and second half of the linprog output. Make sense?
Alan Weiss
MATLAB mathematical toolbox documentation
  2 Comments
Rafael
Rafael on 27 Aug 2014
Thanks. I had done this earlier, but I made some serious mistakes that was giving me an unfeasible answer. Fixed and now works properly, tyvm
Matt J
Matt J on 29 Aug 2014
Edited: Matt J on 29 Aug 2014
@Rafael, it seems like a bad idea though. Solving 2 lower dimensional linear programs is better/faster, I would expect, than solving 1 higher dimensional one.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!