ANN: PuLP, a Python LP (linear program) modeler

Jean-Sebastien Roy js@jeannot.org
Sun, 07 Mar 2004 15:59:32 +0100


I would like to announce the release of PuLP v 1.0.

PuLP is an LP modeler written in python. PuLP can generate MPS or LP 
files
and call GLPK[1], COIN CLP/SBB[2], CPLEX[3] and XPRESS[4] to solve linear
problems.

PuLP provides a nice syntax for the creation of linear problems, and a 
simple way
to call the solvers to perform the optimization. See the example below.

You can get it at:
http://www.jeannot.org/~js/code/pulp-1.0.tgz

The latest version is always available at:
http://www.jeannot.org/~js/code/index.en.html

Multiple examples are provided.

Thanks,

Jean-Sebastien

References:
[1] http://www.gnu.org/software/glpk/glpk.html
[2] http://www.coin-or.org/
[3] http://www.cplex.com/
[4] http://www.dashoptimization.com/

Example script:

from pulp import *

prob = LpProblem("test1", LpMinimize)

# Variables
x = LpVariable("x", 0, 4)
y = LpVariable("y", -1, 1)
z = LpVariable("z", 0)

# Objective
prob += x + 4*y + 9*z

# Constraints
prob += x+y <= 5
prob += x+z >= 10
prob += -y+z == 7

GLPK().solve(prob)

# Solution
for v in prob.variables():
   print v.name, "=", v.varValue

print "objective=", value(prob.objective)