1

I want to enumerate all basic feasible solutions of a linear program. How can I do that with PuLP?

I've read PuLP documentation, but couldn't find out how to do it. Your help would really be appreciated.

Rodrigo de Azevedo
  • 1,097
  • 9
  • 17
nemy
  • 519
  • 5
  • 16

1 Answers1

1

You can do this with Pulp, but it is not easy (and of course only works for small problems).

First encode the basis by binary variables. I.e.

b(i) = 1 if x(i) is basic (x(i) are all variables: structural and logical)
       0 otherwise

Then add the constraints:

1. if b(i)=0 then x(i)=0 (i.e. if nonbasic then the variable should
                          be zero -- assuming non-negative variables).
2. sum(i, b(i)) = m      (the number of basic variables is equal to 
                          the number of constraints) 

Then use this algorithm:

step 1. Solve as a MIP.
        If infeasible: STOP 
step 2. Add cut to prevent the previous basis
        Go to step 1.

The basic algorithm is explained here except there we stop a bit earlier: as soon as the objective deteriorates. That would enumerate all optimal bases.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • Thank you! It works and is easy to customize. It's a nice solution. However, I think this method computes same basic feasible solutions until finding optimal one for each run of Pulp. If we can use the information of such intermediate solutions to make Pulp avoid searching the same path many times, this method may be faster. Is it possible to do this? – nemy Feb 14 '19 at 14:58
  • If there are degenerate solutions, you will see multiple bases corresponding to what looks like a single solution. The Simplex method has the same problem: some iterations cause a basis change but no progress. If you are familiar with linear programming this should not come as a suprise. – Erwin Kalvelagen Feb 14 '19 at 16:06