Skip to content

Commit

Permalink
xpress in github actions (#687)
Browse files Browse the repository at this point in the history
* first test

* xpress is not available in 3.11 for macOS apparently.
  • Loading branch information
pchtsp authored Sep 30, 2023
1 parent fa699ae commit 2fe7162
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: install glpk
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -qq
sudo apt-get install -qq glpk-utils
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: install xpress
if: matrix.os != 'macOS-latest' || matrix.python-version < '3.11'
run: pip install xpress
- name: Install gurobipy
run: |
python -m pip install gurobipy
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 @@ -1340,7 +1340,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 2fe7162

Please sign in to comment.