# 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 ‘...’

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)

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()
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=[])

The CPLEX LP solver

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
defaultPath()
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

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
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=[])

The GLPK LP solver

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
defaultPath()
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

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=[])

The XPRESS LP solver

actualSolve(lp)
Solve a well formulated lp problem
available()
True if the solver is available
defaultPath()
{"ft_lang_label":"__label__en","ft_lang_prob":0.7107283,"math_prob":0.8392478,"size":6749,"snap":"2020-24-2020-29","text_gpt3_token_len":1822,"char_repetition_ratio":0.16560414,"word_repetition_ratio":0.25496343,"special_character_ratio":0.24018373,"punctuation_ratio":0.14453782,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96272486,"pos_list":[0,1,2],"im_url_duplicate_count":[null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-04T18:00:40Z\",\"WARC-Record-ID\":\"<urn:uuid:81e39f1a-059d-49f0-b160-303927630c05>\",\"Content-Length\":\"32177\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bcbe830c-7c6c-4a27-baae-ea5fd6f6d297>\",\"WARC-Concurrent-To\":\"<urn:uuid:bd260c5f-8240-4a9b-9f74-8adab5190bea>\",\"WARC-IP-Address\":\"130.127.206.21\",\"WARC-Target-URI\":\"https://www.coin-or.org/PuLP/solvers.html\",\"WARC-Payload-Digest\":\"sha1:UPR7B26ZU7HWOFY3SAAYWKHRGFFXWCJY\",\"WARC-Block-Digest\":\"sha1:PGSUVVVFWRE6AMWIQ4PEQHKVME3FYR6V\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655886516.43_warc_CC-MAIN-20200704170556-20200704200556-00470.warc.gz\"}"}