pulp.apis
Interface to Solvers
- class pulp.apis.CHOCO_CMD(path=None, keepFiles=False, mip=True, msg=True, options=None, timeLimit=None)
Bases:
LpSolver_CMD
The CHOCO_CMD solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
options (list) – list of additional options to pass to solver
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- name = 'CHOCO_CMD'
- static readsol(filename)
Read a Choco solution file
- class pulp.apis.COINMP_DLL(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The COIN_MP LP MIP solver (via a DLL or linux so)
- Parameters:
timeLimit (float) – The number of seconds before forcing the solver to exit
epgap – The fractional mip tolerance
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
options (list)
timeLimit – maximum time for solver (in seconds)
args
kwargs – optional named options to pass to each solver, e.g. gapRel=0.1, gapAbs=10, logPath=””,
- actualSolve(lp)
Solve a well formulated lp problem
- classmethod available()
True if the solver is available
- name = 'COINMP_DLL'
- pulp.apis.COINMP_DLL_load_dll(path)
function that loads the DLL useful for debugging installation problems
- class pulp.apis.COIN_CMD(mip=True, msg=True, timeLimit=None, gapRel=None, gapAbs=None, presolve=None, cuts=None, strong=None, options=None, warmStart=False, keepFiles=False, path=None, threads=None, logPath=None, timeMode='elapsed', maxNodes=None)
Bases:
LpSolver_CMD
The COIN CLP/CBC LP solver now only uses cbc
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
threads (int) – sets the maximum number of threads
options (list) – list of additional options to pass to solver
warmStart (bool) – if True, the solver will use the current value of variables as a start
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
logPath (str) – path to the log file
presolve (bool) – if True, adds presolve on, if False, adds presolve off
cuts (bool) – if True, adds gomory on knapsack on probing on, if False adds cuts off
strong (int) – number of variables to look at in strong branching (range is 0 to 2147483647)
timeMode (str) – “elapsed”: count wall-time to timeLimit; “cpu”: count cpu-time
maxNodes (int) – max number of nodes during branching. Stops the solving when reached.
- actualSolve(lp, **kwargs)
Solve a well formulated lp problem
- available()
True if the solver is available
- copy()
Make a copy of self
- defaultPath()
- getOptions()
- get_status(filename)
- name = 'COIN_CMD'
- readsol_LP(filename, lp, vs)
Read a CBC solution file generated from an lp (good names) returns status, values, reducedCosts, shadowPrices, slacks, sol_status
- readsol_MPS(filename, lp, vs, variablesNames, constraintsNames, objectiveName=None)
Read a CBC solution file generated from an mps or lp file (possible different names)
- solve_CBC(lp, use_mps=True)
Solve a MIP problem using CBC
- writesol(filename, lp, vs, variablesNames, constraintsNames)
Writes a CBC solution file generated from an mps / lp file (possible different names) returns True on success
- class pulp.apis.COPT(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The COPT Optimizer via its python interface
The COPT variables are available (after a solve) in var.solverVar Constraints in constraint.solverConstraint and the Model is in prob.solverModel
- Parameters:
- actualSolve(lp, callback=None)
Solve a well formulated lp problem
- available()
True if the solver is available
- name = 'COPT'
- class pulp.apis.COPT_CMD(path=None, keepFiles=0, mip=True, msg=True, mip_start=False, warmStart=False, logfile=None, **params)
Bases:
LpSolver_CMD
The COPT command-line solver
Initialize command-line solver
- actualSolve(lp)
Solve a well formulated LP problem
This function borrowed implementation of CPLEX_CMD.actualSolve and GUROBI_CMD.actualSolve, with some modifications.
- available()
True if ‘copt_cmd’ is available
- defaultPath()
The default path of ‘copt_cmd’
- name = 'COPT_CMD'
- readsol(filename)
Read COPT solution file
- writemst(filename, lpvars)
Write COPT MIP start file
- class pulp.apis.COPT_DLL(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The COPT dynamic library solver
- Parameters:
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- err = TypeError('expected str, bytes or os.PathLike object, not NoneType')
- name = 'COPT_DLL'
- pulp.apis.COPT_DLL_loadlib()
Load COPT shared library in all supported platforms
- class pulp.apis.CPLEX_CMD(mip=True, msg=True, timeLimit=None, gapRel=None, gapAbs=None, options=None, warmStart=False, keepFiles=False, path=None, threads=None, logPath=None, maxMemory=None, maxNodes=None)
Bases:
LpSolver_CMD
The CPLEX LP solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
threads (int) – sets the maximum number of threads
options (list) – list of additional options to pass to solver
warmStart (bool) – if True, the solver will use the current value of variables as a start
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
logPath (str) – path to the log file
maxMemory (float) – max memory to use during the solving. Stops the solving when reached.
maxNodes (int) – max number of nodes during branching. Stops the solving when reached.
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- getOptions()
- name = 'CPLEX_CMD'
- readsol(filename)
Read a CPLEX solution file
- writesol(filename, vs)
Writes a CPLEX solution file
- class pulp.apis.CPLEX_PY(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The CPLEX LP/MIP solver (via a Python Binding)
This solver wraps the python api of cplex. It has been tested against cplex 12.3. For api functions that have not been wrapped in this solver please use the base cplex classes
- Parameters:
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- err = ModuleNotFoundError("No module named 'cplex'")
- name = 'CPLEX_PY'
- class pulp.apis.FSCIP_CMD(path=None, mip=True, keepFiles=False, msg=True, options=None, timeLimit=None, gapRel=None, gapAbs=None, maxNodes=None, threads=None, logPath=None)
Bases:
LpSolver_CMD
The multi-threaded FiberSCIP version of the SCIP optimization solver
- Parameters:
msg (bool) – if False, no log is shown
mip (bool) – if False, assume LP even if integer variables
options (list) – list of additional options to pass to solver
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
maxNodes (int) – max number of nodes during branching. Stops the solving when reached.
threads (int) – sets the maximum number of threads
logPath (str) – path to the log file
- FSCIP_STATUSES = {'Final Solution': 1, 'No Solution': 0}
- NO_SOLUTION_STATUSES = {-2, -1, 0}
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- name = 'FSCIP_CMD'
- static readsol(filename)
Read a FSCIP solution file
- class pulp.apis.GLPK_CMD(path=None, keepFiles=False, mip=True, msg=True, options=None, timeLimit=None)
Bases:
LpSolver_CMD
The GLPK LP solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
options (list) – list of additional options to pass to solver
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- name = 'GLPK_CMD'
- readsol(filename)
Read a GLPK solution file
- class pulp.apis.GUROBI(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The Gurobi LP/MIP solver (via its python interface)
The Gurobi variables are available (after a solve) in var.solverVar Constraints in constraint.solverConstraint and the Model is in prob.solverModel
- Parameters:
- actualSolve(lp, callback=None)
Solve a well formulated lp problem
- available()
True if the solver is available
- env = None
- name = 'GUROBI'
- class pulp.apis.GUROBI_CMD(mip=True, msg=True, timeLimit=None, gapRel=None, gapAbs=None, options=None, warmStart=False, keepFiles=False, path=None, threads=None, logPath=None, mip_start=False)
Bases:
LpSolver_CMD
The GUROBI_CMD solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
threads (int) – sets the maximum number of threads
options (list) – list of additional options to pass to solver
warmStart (bool) – if True, the solver will use the current value of variables as a start
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
logPath (str) – path to the log file
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- getOptions()
- name = 'GUROBI_CMD'
- readsol(filename)
Read a Gurobi solution file
- writesol(filename, vs)
Writes a GUROBI solution file
- class pulp.apis.HiGHS(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
- Parameters:
- actualSolve(lp, callback=None)
Solve a well formulated lp problem
- available()
True if the solver is available
- name = 'HiGHS'
- class pulp.apis.HiGHS_CMD(path=None, keepFiles=False, mip=True, msg=True, options=None, timeLimit=None, gapRel=None, gapAbs=None, threads=None, logPath=None, warmStart=False)
Bases:
LpSolver_CMD
The HiGHS_CMD solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
options (list[str]) – list of additional options to pass to solver
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary (you can get binaries for your platform from https://github.com/JuliaBinaryWrappers/HiGHS_jll.jl/releases, or else compile from source - https://highs.dev)
threads (int) – sets the maximum number of threads
logPath (str) – path to the log file
warmStart (bool) – if True, the solver will use the current value of variables as a start
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- readsol(filename)
Read a HiGHS solution file
- writesol(filename, lp)
Writes a HiGHS solution file
- class pulp.apis.LpSolver(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
object
A generic LP Solver
- Parameters:
- actualResolve(lp, **kwargs)
uses existing problem information and solves the problem If it is not implemented 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=None, LpVarCategories=None, LpObjSenses=None, infBound=1e+20)
returns the arrays suitable to pass to a cdll Cplex or other solvers that are similar
Copyright (c) Stuart Mitchell 2007
- name = 'LpSolver'
- solve(lp)
Solve the problem lp
- toDict()
- toJson(filename, *args, **kwargs)
- to_dict()
- to_json(filename, *args, **kwargs)
- class pulp.apis.LpSolver_CMD(path=None, keepFiles=False, *args, **kwargs)
Bases:
LpSolver
A generic command line LP Solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
options (list) – list of additional options to pass to solver (format depends on the solver)
timeLimit (float) – maximum time for solver (in seconds)
path (str) – a path to the solver binary
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
args – parameters to pass to
LpSolver
kwargs – parameters to pass to
LpSolver
- copy()
Make a copy of self
- create_tmp_files(name, *args)
- defaultPath()
- delete_tmp_files(*args)
- static executable(command)
Checks that the solver command is executable, And returns the actual path to it.
- static executableExtension(name)
- name = 'LpSolver_CMD'
- setTmpDir()
Set the tmpDir attribute to a reasonnable location for a temporary directory
- class pulp.apis.MIPCL_CMD(path=None, keepFiles=False, mip=True, msg=True, options=None, timeLimit=None)
Bases:
LpSolver_CMD
The MIPCL_CMD solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
options (list) – list of additional options to pass to solver
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- name = 'MIPCL_CMD'
- static readsol(filename)
Read a MIPCL solution file
- class pulp.apis.MOSEK(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
Mosek lp and mip solver (via Mosek Optimizer API).
- Parameters:
- actualSolve(lp, callback=None)
Solves a well-formulated lp problem.
- available()
True if Mosek is available.
- name = 'MOSEK'
- class pulp.apis.PULP_CBC_CMD(mip=True, msg=True, timeLimit=None, gapRel=None, gapAbs=None, presolve=None, cuts=None, strong=None, options=None, warmStart=False, keepFiles=False, path=None, threads=None, logPath=None, timeMode='elapsed', maxNodes=None)
Bases:
COIN_CMD
This solver uses a precompiled version of cbc provided with the package
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
threads (int) – sets the maximum number of threads
options (list) – list of additional options to pass to solver
warmStart (bool) – if True, the solver will use the current value of variables as a start
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
logPath (str) – path to the log file
presolve (bool) – if True, adds presolve on, if False, adds presolve off
cuts (bool) – if True, adds gomory on knapsack on probing on, if False adds cuts off
strong (int) – number of variables to look at in strong branching (range is 0 to 2147483647)
timeMode (str) – “elapsed”: count wall-time to timeLimit; “cpu”: count cpu-time
maxNodes (int) – max number of nodes during branching. Stops the solving when reached.
- name = 'PULP_CBC_CMD'
- pulp_cbc_path = '/home/runner/work/pulp/pulp/pulp/solverdir/cbc/linux/64/cbc'
- class pulp.apis.PYGLPK(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The glpk LP/MIP solver (via its python interface)
Copyright Christophe-Marie Duquesne 2012
The glpk variables are available (after a solve) in var.solverVar The glpk constraints are available in constraint.solverConstraint The Model is in prob.solverModel
- Parameters:
- actualSolve(lp, callback=None)
Solve a well formulated lp problem
- available()
True if the solver is available
- name = 'PYGLPK'
- pulp.apis.Parser
alias of
ConfigParser
- class pulp.apis.SAS94(mip=True, msg=True, warmStart=False, keepFiles=False, timeLimit=None, **solverParams)
Bases:
SASsolver
- Parameters:
- actualSolve(lp, callback=None)
Solves a well-formulated lp problem.
- available()
True if SAS94 is available.
- name = 'SAS94'
- class pulp.apis.SASCAS(mip=True, msg=True, warmStart=False, keepFiles=False, timeLimit=None, **solverParams)
Bases:
SASsolver
- Parameters:
- actualSolve(lp, callback=None)
Solves a well-formulated lp problem.
- available()
True if SASCAS is available.
- name = 'SASCAS'
- class pulp.apis.SASsolver(mip=True, msg=True, warmStart=False, keepFiles=False, timeLimit=None, **solverParams)
Bases:
LpSolver_CMD
- Parameters:
- defaultPath()
- name = 'SASsolver'
- class pulp.apis.SCIP_CMD(path=None, mip=True, keepFiles=False, msg=True, options=None, timeLimit=None, gapRel=None, gapAbs=None, maxNodes=None, logPath=None, threads=None)
Bases:
LpSolver_CMD
The SCIP optimization solver
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
options (list) – list of additional options to pass to solver
keepFiles (bool) – if True, files are saved in the current directory and not deleted after solving
path (str) – path to the solver binary
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
gapAbs (float) – absolute gap tolerance for the solver to stop
maxNodes (int) – max number of nodes during branching. Stops the solving when reached.
threads (int) – sets the maximum number of threads
logPath (str) – path to the log file
- NO_SOLUTION_STATUSES = {-2, -1, 0}
- SCIP_STATUSES = {'gap limit reached': 1, 'infeasible': -1, 'infeasible or unbounded': 0, 'memory limit reached': 0, 'node limit reached': 0, 'optimal solution found': 1, 'restart limit reached': 0, 'solution improvement limit reached': 0, 'solution limit reached': 0, 'stall node limit reached': 0, 'time limit reached': 0, 'total node limit reached': 0, 'unbounded': -2, 'unknown': -3, 'user interrupt': 0}
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- name = 'SCIP_CMD'
- static readsol(filename)
Read a SCIP solution file
- class pulp.apis.SCIP_PY(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
The SCIP Optimization Suite (via its python interface)
The SCIP internals are available after calling solve as: - each variable in variable.solverVar - each constraint in constraint.solverConstraint - the model in problem.solverModel
- Parameters:
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- name = 'SCIP_PY'
- class pulp.apis.StringIO(initial_value='', newline='\n')
Bases:
_TextIOBase
Text I/O implementation using an in-memory buffer.
The initial_value argument sets the value of object. The newline argument is like the one of TextIOWrapper’s constructor.
- close()
Close the IO object.
Attempting any further operation after the object is closed will raise a ValueError.
This method has no effect if the file is already closed.
- closed
- getvalue()
Retrieve the entire contents of the object.
- line_buffering
- newlines
- read(size=-1, /)
Read at most size characters, returned as a string.
If the argument is negative or omitted, read until EOF is reached. Return an empty string at EOF.
- readable()
Returns True if the IO object can be read.
- readline(size=-1, /)
Read until newline or EOF.
Returns an empty string if EOF is hit immediately.
- seek(pos, whence=0, /)
Change stream position.
- Seek to character offset pos relative to position indicated by whence:
0 Start of stream (the default). pos should be >= 0; 1 Current position - pos must be 0; 2 End of stream - pos must be 0.
Returns the new absolute position.
- seekable()
Returns True if the IO object can be seeked.
- tell()
Tell the current file position.
- truncate(pos=None, /)
Truncate size to pos.
The pos argument defaults to the current file position, as returned by tell(). The current file position is unchanged. Returns the new absolute position.
- writable()
Returns True if the IO object can be written.
- write(s, /)
Write string to file.
Returns the number of characters written, which is always equal to the length of the string.
- class pulp.apis.XPRESS(mip=True, msg=True, timeLimit=None, gapRel=None, options=None, keepFiles=False, path=None, heurFreq=None, heurStra=None, coverCuts=None, preSolve=None, warmStart=False)
Bases:
LpSolver_CMD
The XPRESS LP solver that uses the XPRESS command line tool in a subprocess
Initializes the Xpress solver.
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
heurFreq – the frequency at which heuristics are used in the tree search
heurStra – heuristic strategy
coverCuts – the number of rounds of lifted cover inequalities at the top node
preSolve – whether presolving should be performed before the main algorithm
options – Adding more options, e.g. options = [“NODESELECTION=1”, “HEURDEPTH=5”] More about Xpress options and control parameters please see https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/chapter7.html
warmStart (bool) – if True, then use current variable values as start
- actualSolve(lp)
Solve a well formulated lp problem
- available()
True if the solver is available
- defaultPath()
- name = 'XPRESS'
- static quote_path(path)
Quotes a path for the Xpress optimizer console, by wrapping it in double quotes and escaping the following characters, which would otherwise be interpreted by the Tcl shell: $ “ [
- static readsol(filename, attrfile)
Read an XPRESS solution file
- writeslxsol(name, *values)
Write a solution file in SLX format. The function can write multiple solutions to the same file, each solution must be passed as a list of (name,value) pairs. Solutions are written in the order specified and are given names “solutionN” where N is the index of the solution in the list.
- Parameters:
name (string) – file name
values (list) – list of lists of (name,value) pairs
- class pulp.apis.XPRESS_PY(mip=True, msg=True, timeLimit=None, gapRel=None, heurFreq=None, heurStra=None, coverCuts=None, preSolve=None, warmStart=None, export=None, options=None)
Bases:
LpSolver
The XPRESS LP solver that uses XPRESS Python API
Initializes the Xpress solver.
- Parameters:
mip (bool) – if False, assume LP even if integer variables
msg (bool) – if False, no log is shown
timeLimit (float) – maximum time for solver (in seconds)
gapRel (float) – relative gap tolerance for the solver to stop (in fraction)
heurFreq – the frequency at which heuristics are used in the tree search
heurStra – heuristic strategy
coverCuts – the number of rounds of lifted cover inequalities at the top node
preSolve – whether presolving should be performed before the main algorithm
warmStart (bool) – if set then use current variable values as warm start
export (string) – if set then the model will be exported to this file before solving
options – Adding more options. This is a list the elements of which are either (name,value) pairs or strings “name=value”. More about Xpress options and control parameters please see https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/chapter7.html
- actualResolve(lp, prepare=None)
Resolve a problem that was previously solved by actualSolve().
- actualSolve(lp, prepare=None)
Solve a well formulated lp problem
- available()
True if the solver is available
- buildSolverModel(lp)
Takes the pulp lp model and translates it into an xpress model
- callSolver(lp, prepare=None)
Perform the actual solve from actualSolve() or actualResolve().
- Parameters:
prepare – a function that is called with lp as argument and allows final tweaks to lp.solverModel before the low level solve is started.
- findSolutionValues(lp)
- getAttribute(lp, which)
Get an arbitrary attribute for the model that was previously solved using actualSolve().
- name = 'XPRESS_PY'
- class pulp.apis.YAPOSIB(mip=True, msg=True, options=None, timeLimit=None, *args, **kwargs)
Bases:
LpSolver
COIN OSI (via its python interface)
Copyright Christophe-Marie Duquesne 2012
The yaposib variables are available (after a solve) in var.solverVar The yaposib constraints are available in constraint.solverConstraint The Model is in prob.solverModel
- Parameters:
- actualSolve(lp, callback=None)
Solve a well formulated lp problem
- available()
True if the solver is available
- name = 'YAPOSIB'
- pulp.apis.byref(C instance[, offset=0]) byref-object
Return a pointer lookalike to a C instance, only usable as function argument
- pulp.apis.clock()
monotonic() -> float
Monotonic clock, cannot go backward.
- pulp.apis.configSolvers()
Configure the path the the solvers on the command line
Designed to configure the file locations of the solvers from the command line after installation
- pulp.apis.coptstr(x)
- pulp.apis.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.apis.getSolver(solver, *args, **kwargs)
Instantiates a solver from its name
- pulp.apis.getSolverFromDict(data)
Instantiates a solver from a dictionary with its data
- Parameters:
data (dict) – a dictionary with, at least an “solver” key with the name of the solver to create
- Returns:
a solver of type
LpSolver
- Raises:
PulpSolverError – if the dictionary does not have the “solver” key
- Return type:
- pulp.apis.getSolverFromJson(filename)
Instantiates a solver from a json file with its data
- pulp.apis.initialize(filename, operating_system='linux', arch='64')
reads the configuration file to initialise the module
- pulp.apis.listSolvers(onlyAvailable=False)
List the names of all the existing solvers in PuLP
- pulp.apis.mktemp(suffix='', prefix='tmp', dir=None)
User-callable function to return a unique temporary file name. The file is not created.
Arguments are similar to mkstemp, except that the ‘text’ argument is not accepted, and suffix=None, prefix=None and bytes file names are not supported.
THIS FUNCTION IS UNSAFE AND SHOULD NOT BE USED. The file name may refer to a file that did not exist at some point, but by the time you get around to creating it, someone else may have beaten you to the punch.
- class pulp.apis.redirect_stdout(new_target)
Bases:
_RedirectStream
Context manager for temporarily redirecting stdout to another file.
# How to send help() to stderr with redirect_stdout(sys.stderr):
help(dir)
# How to write help() to a file with open(‘help.txt’, ‘w’) as f:
- with redirect_stdout(f):
help(pow)
- pulp.apis.setConfigInformation(**keywords)
set the data in the configuration file at the moment will only edit things in [locations] the keyword value pairs come from the keywords dictionary
- pulp.apis.to_string(_obj)
- pulp.apis.uuid4()
Generate a random UUID.