How to use linprog only once for two different constraints

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?

 Réponse acceptée

Alan Weiss
Alan Weiss le 27 Août 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 commentaires

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 le 29 Août 2014
Modifié(e) : Matt J le 29 Août 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Linear Programming and Mixed-Integer Linear Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by