I solved the following linear program with scipy.optimize.linprog:
result = linprog(
[0, 0, 0, 0],
A_eq=[
[1, 1, 0, 0],
[1, 0, 1, 1]
],
b_eq=[
-10000, -10000
],
bounds=[(None, -1000), (None, -1000), (None, -1000), (None, -1000)]
)
print(result.x)
And got:
[-4982.07750764 -5017.92249214 -2508.96124608 -2508.96124608]
This program has many solutions that are numerically "nicer" (have more round numbers), for example:
[-5000 -5000 -2500 -2500]
Is there a way to tell linprog to prefer such solutions?
By default, linprog
will use an interior point method. This will give correct solutions, but they often don't look very nice. The simplex method usually gives "nicer" solutions. When we add the argument method = 'revised simplex'
, we see:
[-1000. -9000. -1000. -8000.]
Still not unique of course, but it looks a bit better.