Skip to content

Commit

Permalink
updated docs on adding a new solver
Browse files Browse the repository at this point in the history
  • Loading branch information
pchtsp committed Aug 31, 2021
1 parent 469ef50 commit 6a24ed5
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions doc/source/develop/add_solver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ General information on configuring solvers and how pulp finds solvers installed
Example
----------

The smallest api for a solver can be found in the file :py:class:`pulp.apis.mipcl_api.MIPCL_CMD` located in ``pulp/apis/mipcl_api.py``. We will use it as an example.
The smallest api for a solver can be found in the file :py:class:`pulp.apis.mipcl_api.MIPCL_CMD` located in ``pulp/apis/mipcl_api.py``. We will use it as an example to list all the changes that need to be done.


Inheriting basic classes
Inheriting base classes
------------------------------

The solver needs to inherit one of two classes: :py:class:`pulp.apis.LpSolver` or :py:class:`pulp.apis.LpSolver_CMD` located in ``pulp.apis.core.py``. The first one is a generic class. The second one is used for command-line based APIs to solvers. This is the one used for the example::
Expand Down Expand Up @@ -136,3 +135,22 @@ Only required by :py:class:`pulp.apis.LpSolver_CMD`. It returns the default path
return self.executableExtension("mps_mipcl")


Making the solver available to PuLP
---------------------------------------------------

Modify the ``pulp/apis/__init__.py`` file to import your solver and add it to the ``_all_solvers`` list::

from .mipcl_api import MIPCL_CMD
_all_solvers = [
# (...)
MIPCL_CMD,
]

Including the solver in tests suite
--------------------------------------------------

Include the solver in PuLP's test suite by adding a couple of lines corresponding to your solver to the ``pulp/tests/test_pulp.py`` file::

# (...)
class MIPCL_CMDTest(BaseSolverTest.PuLPTest):
solveInst = MIPCL_CMD

0 comments on commit 6a24ed5

Please sign in to comment.