pulp.solvers Interface to Solvers

This file contains the solver classes for PuLP Note that the solvers that require a compiled extension may not work in the current version

pulp.solvers.COIN
alias of COINMP_DLL
class pulp.solvers.COINMP_DLL(mip=1, msg=1, cuts=1, presolve=1, dual=1, crash=0, scale=1, rounding=1, integerPresolve=1, strong=5, timeLimit=None, epgap=None)

Bases: pulp.solvers.LpSolver

The COIN_MP LP MIP solver (via a DLL or linux so)

actualSolve(lp)
Solve a well formulated lp problem
classmethod available()
True if the solver is available
copy()
Make a copy of self
getSolverVersion()

returns a solver version string

example: >>> COINMP_DLL().getSolverVersion() # doctest: +ELLIPSIS ‘...’

pulp.solvers.COINMP_DLL_load_dll(path)
function that loads the DLL useful for debugging installation problems
class pulp.solvers.COIN_CMD(path=None, keepFiles=0, mip=1, msg=0, cuts=None, presolve=None, dual=None, strong=None, options=[], fracGap=None, maxSeconds=None, threads=None)

Bases: pulp.solvers.LpSolver_CMD

The COIN CLP/CBC LP solver now only uses cbc

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
copy()
Make a copy of self
defaultPath()
readsol_CBC(filename, lp, vs)
Read a CBC solution file
solve_CBC(lp)
Solve a MIP problem using CBC
pulp.solvers.CPLEX
alias of CPLEX_DLL
class pulp.solvers.CPLEX_CMD(path=None, keepFiles=0, mip=1, msg=1, options=[])

Bases: pulp.solvers.LpSolver_CMD

The CPLEX LP solver

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
defaultPath()
readsol(filename)
Read a CPLEX solution file
class pulp.solvers.CPLEX_DLL(mip=True, msg=True, timeLimit=None, epgap=None, logfilename=None, emphasizeMemory=False)

Bases: pulp.solvers.LpSolver

The CPLEX LP/MIP solver (via a Dynamic library DLL - windows or SO - Linux)

This solver wraps the c library api of cplex. It has been tested against cplex 11. For api functions that have not been wrapped in this solver please use the ctypes library interface to the cplex api in CPLEX_DLL.lib

Initializes the CPLEX_DLL solver.

@param mip: if False the solver will solve a MIP as an LP @param msg: displays information from the solver to stdout @param epgap: sets the integer bound gap @param logfilename: sets the filename of the cplex logfile @param emphasizeMemory: makes the solver emphasize Memory over

solution time
actualResolve(lp)
looks at which variables have been modified and changes them
actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
callSolver(isMIP)
Solves the problem with cplex
changeEpgap(epgap=0.0001)
Change cplex solver integer bound gap tolerence
findSolutionValues(lp, numcols, numrows)
getSparseCols(vars, lp, offset=0, defBound=1e+20)

outputs the variables in var as a sparse matrix, suitable for cplex and Coin

Copyright (c) Stuart Mitchell 2007

grabLicence()
Returns True if a CPLEX licence can be obtained. The licence is kept until releaseLicence() is called.
releaseLicence()
Release a previously obtained CPLEX licence
setMemoryEmphasis(yesOrNo=False)
Make cplex try to conserve memory at the expense of performance.
setTimeLimit(timeLimit=0.0)
Make cplex limit the time it takes –added CBM 8/28/09
setlogfile(filename)
sets the logfile for cplex output
pulp.solvers.CPLEX_DLL_load_dll(path)
function that loads the DLL useful for debugging installation problems
pulp.solvers.GLPK
alias of GLPK_CMD
class pulp.solvers.GLPK_CMD(path=None, keepFiles=0, mip=1, msg=1, options=[])

Bases: pulp.solvers.LpSolver_CMD

The GLPK LP solver

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
defaultPath()
readsol(filename)
Read a GLPK solution file
class pulp.solvers.GUROBI(mip=True, msg=True, timeLimit=None, epgap=None, **solverParams)

Bases: pulp.solvers.LpSolver

The Gurobi LP/MIP solver (via its python interface)

The Gurobi variables are available (after a solve) in var.solverVar Constriaints in constraint.solverConstraint and the Model is in prob.solverModel

Initializes the Gurobi solver.

@param mip: if False the solver will solve a MIP as an LP @param msg: displays information from the solver to stdout @param timeLimit: sets the maximum time for solution @param epgap: sets the integer bound gap

actualResolve(lp, callback=None)

Solve a well formulated lp problem

uses the old solver and modifies the rhs of the modified constraints

actualSolve(lp, callback=None)

Solve a well formulated lp problem

creates a gurobi model, variables and constraints and attaches them to the lp model which it then solves

available()
True if the solver is available
buildSolverModel(lp)
Takes the pulp lp model and translates it into a gurobi model
callSolver(lp, callback=None)
Solves the problem with gurobi
findSolutionValues(lp)
class pulp.solvers.LpSolver(mip=True, msg=True, options=[], *args, **kwargs)

A generic LP Solver

actualResolve(lp, **kwargs)
uses existing problem information and solves the problem If it is not implelemented in the solver just solve again
actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
copy()
Make a copy of self
getCplexStyleArrays(lp, senseDict={0: 'E', 1: 'G', -1: 'L'}, LpVarCategories={'Integer': 'I', 'Continuous': 'C'}, LpObjSenses={1: 1, -1: -1}, infBound=1e+20)

returns the arrays suitable to pass to a cdll Cplex or other solvers that are similar

Copyright (c) Stuart Mitchell 2007

solve(lp)
Solve the problem lp
class pulp.solvers.LpSolver_CMD(path=None, keepFiles=0, mip=1, msg=1, options=[])

Bases: pulp.solvers.LpSolver

A generic command line LP Solver

copy()
Make a copy of self
defaultPath()
static executable(command)
Checks that the solver command is executable, And returns the actual path to it.
static executableExtension(name)
setTmpDir()
Set the tmpDir attribute to a reasonnable location for a temporary directory
exception pulp.solvers.PulpSolverError

Bases: exceptions.Exception

Pulp Solver-related exceptions

class pulp.solvers.XPRESS(path=None, keepFiles=0, mip=1, msg=1, options=[])

Bases: pulp.solvers.LpSolver_CMD

The XPRESS LP solver

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
defaultPath()
readsol(filename)
Read an XPRESS solution file
pulp.solvers.ctypesArrayFill(myList, type=<class 'ctypes.c_double'>)
Creates a c array with ctypes from a python list type is the type of the c array
pulp.solvers.initialize(filename)
reads the configuration file to initialise the module

Previous topic

pulp: Pulp classes

This Page

Creative Commons License
PuLP documentation by Pulp documentation team is licensed under a Creative Commons Attribution-Share Alike 3.0 New Zealand License.