Skip to content

Commit

Permalink
first test
Browse files Browse the repository at this point in the history
  • Loading branch information
pchtsp committed Oct 13, 2022
1 parent ff8d48f commit 4001051
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
run: |
sudo apt-get update -qq
sudo apt-get install -qq glpk-utils
- name: install xpress
run: pip install xpress
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
18 changes: 18 additions & 0 deletions doc/source/develop/add_solver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,21 @@ Include the solver in PuLP's test suite by adding a couple of lines correspondin
# (...)
class MIPCL_CMDTest(BaseSolverTest.PuLPTest):
solveInst = MIPCL_CMD


Extra: adding a official solver API
---------------------------------------------

There are additional best practices to take into account with these solvers. The ``actualSolve`` method has the following structure::

def actualSolve(self, lp):
self.buildSolverModel(lp)
# set the initial solution
self.callSolver(lp)
# get the solution information
solutionStatus = self.findSolutionValues(lp)
return solutionStatus

In addition to this, the ``buildSolverModel`` method fills a property named `lp.solverModel` in the LP problem. This property will include a pointer to the model object from the official solver API (e.g., ``gurobipy.Model`` for GUROBI).

These considerations will permit a consistent, more standard way to call official solvers. In particular, they allow for detailed configuration, such as the one explained :ref:`here <solver-specific-config>`.
3 changes: 3 additions & 0 deletions doc/source/guides/how_to_configure_solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ PuLP has the integrations with the official python API solvers for the following
* Mosek (MOSEK)
* Gurobi (GUROBI)
* Cplex (CPLEX_PY)
* Xpress (XPRESS_PY)

These API offer a series of advantages over using the command line option:

Expand Down Expand Up @@ -218,9 +219,11 @@ Following my installation paths it would be (Linux):

As you can see, it is necessary to have admin rights to install it.

.. _solver-specific-config:
Using solver-specific functionality
**********************************************


In order to access this functionality, the user needs to use the solver object included inside the PuLP problem. PuLP uses the ``solverModel`` attribute on the problem object. This attribute is created and filled when the method ``buildSolverModel()`` is executed.

For example, using the ``CPLEX_PY`` API we can access the api object after the solving is done:
Expand Down
2 changes: 1 addition & 1 deletion pulp/tests/test_pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def test_LpVariable_indexs_param(self):
print("\t Testing 'indexs' param continues to work for LpVariable.matrix")
# explicit param creates list of list of LpVariable
assign_vars_matrix = LpVariable.matrix(
name="test", indexs=(customers, agents)
name="test", indices=(customers, agents)
)
for a in assign_vars_matrix:
for b in a:
Expand Down

0 comments on commit 4001051

Please sign in to comment.