From 4001051f6e2ee44b7253ff4a86ba07d3c1c1c6ef Mon Sep 17 00:00:00 2001 From: pchtsp Date: Thu, 13 Oct 2022 19:34:40 +0200 Subject: [PATCH] first test --- .github/workflows/pythonpackage.yml | 2 ++ doc/source/develop/add_solver.rst | 18 ++++++++++++++++++ doc/source/guides/how_to_configure_solvers.rst | 3 +++ pulp/tests/test_pulp.py | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index a2ad8e6e..eb8e52e9 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -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 diff --git a/doc/source/develop/add_solver.rst b/doc/source/develop/add_solver.rst index 548506d3..6beb4b9d 100644 --- a/doc/source/develop/add_solver.rst +++ b/doc/source/develop/add_solver.rst @@ -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 `. \ No newline at end of file diff --git a/doc/source/guides/how_to_configure_solvers.rst b/doc/source/guides/how_to_configure_solvers.rst index 3291df89..7b8a7ea0 100644 --- a/doc/source/guides/how_to_configure_solvers.rst +++ b/doc/source/guides/how_to_configure_solvers.rst @@ -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: @@ -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: diff --git a/pulp/tests/test_pulp.py b/pulp/tests/test_pulp.py index f9e2d940..fd31c7f4 100644 --- a/pulp/tests/test_pulp.py +++ b/pulp/tests/test_pulp.py @@ -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: