0

I'm using Pulp to solve a linear program (also getting the same result with scipy). So something wrong with my linear program formulation, or I don't know some tricky details on how simplex algorithm works.

Here is objective function for minimisation, notice that multiplier for x2 is 0, so I don't expect x1 or x2 to have any value except 0, because x3 doesn't have max constraint and -1 * x3 is able to provide more value for minimisation:

Objective function

System of linear equations:

System of linear equations

As a solution I'm getting x2 = 20 even if its multiplier in objective function is 0.

Linear program result

If in objective function I set -2 * x3, then it works just fine.

Rusty Robot
  • 1,305
  • 1
  • 12
  • 18
  • What problem (e.g., resource allocation, scheduling) are you trying to model with this linear program? your objective function is a bit strange, looks like your are solving a maximization problem but have changed the sign to adjust it. – serge_k Jan 01 '16 at 15:03
  • @serge_k you are right, I'm trying to solve maximization problem (resource allocation), but such solvers as scipy.linprog, produce minimised solutions only, so I had to swap signs for the coefficients in order to make it work as maximization. – Rusty Robot Jan 01 '16 at 15:16
  • Are the variables assumed to be nonnegative? Your answer seems to assume that they are even though you haven't stipulated it, but in that case many of your constraints are redundant. – John Coleman Jan 01 '16 at 15:55
  • @JohnColeman You are correct, I haven't specified those constraints in the equation, but they are specified in [provided code](https://gist.github.com/rustyrobot/0dd0827504d42a33c229#file-pulp-linear-program-L11). In this case 3 last constraints are indeed redundant. – Rusty Robot Jan 01 '16 at 16:12

1 Answers1

2

The solution you've posted gives the objective = -380. Check x=[20,0,0,20,0,20,20,0], the objective function is -380 as well, which implies it's optimal too, hence, you have infinitely many solutions (it's easy to show that any convex combination of this two points is optimal, see any Linear Programming book). The problem is your PuLP solver stopped when it's encountered one optimal extreme point. If you are interested in getting all the optimal extreme points I would recommend you to use Cplex (it's not free but you might be eligible for IBM academic initiatives). Also, you can set a solution method to Dual Simlex in your PuLP solver to make it go in different direction and there is a chance you will get the other extreme point.

serge_k
  • 1,772
  • 2
  • 15
  • 21