Skip to content

Commit

Permalink
Remove choco (#510)
Browse files Browse the repository at this point in the history
* removing packaged choco

* updated history and version
  • Loading branch information
pchtsp authored Dec 4, 2021
1 parent 876ebd3 commit 7b551d9
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 110 deletions.
7 changes: 4 additions & 3 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Copyright S.A.Mitchell (s.mitchell@auckland.ac.nz), 2007-
# Copyright F.Peschiera (pchtsp@gmail.com), 2019-
# See the LICENSE file for copyright information.
2.6.0 2021-
dropped packaged choco
fixed bugs
2.7.0
added HiGHS solver
added pysmps dependency for mps parsing
2.6.0 2021-12-04
dropped packaged choco
fixed bugs
deprecated 'indexs' parameter LpVariable dicts and matrix
2.5.1 2021-09-28
updated docs
Expand Down
4 changes: 2 additions & 2 deletions doc/source/guides/how_to_configure_solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ PuLP has some helper functions that permit a user to query which solvers are ava
import pulp as pl
solver_list = pl.listSolvers()
# ['GLPK_CMD', 'PYGLPK', 'CPLEX_CMD', 'CPLEX_PY', 'CPLEX_DLL', 'GUROBI', 'GUROBI_CMD', 'MOSEK', 'XPRESS', 'PULP_CBC_CMD', 'COIN_CMD', 'COINMP_DLL', 'CHOCO_CMD', 'PULP_CHOCO_CMD', 'MIPCL_CMD', 'SCIP_CMD']
# ['GLPK_CMD', 'PYGLPK', 'CPLEX_CMD', 'CPLEX_PY', 'CPLEX_DLL', 'GUROBI', 'GUROBI_CMD', 'MOSEK', 'XPRESS', 'PULP_CBC_CMD', 'COIN_CMD', 'COINMP_DLL', 'CHOCO_CMD', 'MIPCL_CMD', 'SCIP_CMD']
If passed the `only_available=True` argument, PuLP lists the solvers that are currently available::

import pulp as pl
solver_list = pl.listSolvers(onlyAvailable=True)
# ['GLPK_CMD', 'CPLEX_CMD', 'CPLEX_PY', 'GUROBI', 'GUROBI_CMD', 'PULP_CBC_CMD', 'COIN_CMD', 'PULP_CHOCO_CMD']
# ['GLPK_CMD', 'CPLEX_CMD', 'CPLEX_PY', 'GUROBI', 'GUROBI_CMD', 'PULP_CBC_CMD', 'COIN_CMD']

Also, it's possible to get a solver object by using the name of the solver. Any arguments passed to this function are passed to the constructor:

Expand Down
6 changes: 1 addition & 5 deletions pulp/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
COIN_CMD,
COINMP_DLL,
CHOCO_CMD,
PULP_CHOCO_CMD,
MIPCL_CMD,
SCIP_CMD,
]

try:
import ujson as json
except ImportError:
import json
import json

# Default solver selection
if PULP_CBC_CMD().available():
Expand Down
52 changes: 0 additions & 52 deletions pulp/apis/choco_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."""

from .core import LpSolver_CMD, subprocess, PulpSolverError
from .core import pulp_choco_path
import os
from .. import constants
import warnings
Expand Down Expand Up @@ -157,54 +156,3 @@ def readsol(filename):
values[name] = float(value)

return status, values, sol_status


class PULP_CHOCO_CMD(CHOCO_CMD):
"""
This solver uses a packaged version of choco provided with the package
"""

pulp_choco_path = pulp_choco_path
name = "PULP_CHOCO_CMD"
try:
if os.name != "nt":
if not os.access(pulp_choco_path, os.X_OK):
import stat

os.chmod(pulp_choco_path, stat.S_IXUSR + stat.S_IXOTH)
except: # probably due to incorrect permissions

def available(self):
"""True if the solver is available"""
return False

def actualSolve(self, lp, callback=None):
"""Solve a well formulated lp problem"""
raise PulpSolverError(
"PULP_CHOCO_CMD: Not Available (check permissions on %s)"
% self.pulp_choco_path
)

else:

def __init__(
self,
path=None,
keepFiles=0,
mip=True,
msg=True,
options=None,
timeLimit=None,
):
if path is not None:
raise PulpSolverError("Use CHOCO_CMD if you want to set a path")
# check that the file is executable
CHOCO_CMD.__init__(
self,
path=self.pulp_choco_path,
keepFiles=keepFiles,
mip=mip,
msg=msg,
options=options,
timeLimit=timeLimit,
)
6 changes: 0 additions & 6 deletions pulp/apis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ def initialize(filename, operating_system="linux", arch="64"):
scip_path = config.get("locations", "ScipPath")
except configparser.Error:
scip_path = "scip"
try:
pulp_choco_path = config.get("locations", "PulpChocoPath")
except configparser.Error:
pulp_choco_path = "choco"
for i, path in enumerate(coinMP_path):
if not os.path.dirname(path):
# if no pathname is supplied assume the file is in the same directory
Expand All @@ -164,7 +160,6 @@ def initialize(filename, operating_system="linux", arch="64"):
glpk_path,
pulp_cbc_path,
scip_path,
pulp_choco_path,
)


Expand Down Expand Up @@ -199,7 +194,6 @@ def initialize(filename, operating_system="linux", arch="64"):
glpk_path,
pulp_cbc_path,
scip_path,
pulp_choco_path,
) = initialize(config_filename, operating_system, arch)


Expand Down
2 changes: 1 addition & 1 deletion pulp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
This file contains the constant definitions for PuLP
Note that hopefully these will be changed into something more pythonic
"""
VERSION = "2.5.1"
VERSION = "2.6.0"
EPS = 1e-7

# variable categories
Expand Down
Empty file removed pulp/solverdir/choco/__init__.py
Empty file.
Binary file not shown.
29 changes: 0 additions & 29 deletions pulp/solverdir/choco/license.txt

This file was deleted.

14 changes: 4 additions & 10 deletions pulp/tests/test_pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_pulp_009(self):
{x: 4, y: -1, z: 6, w: 0},
use_mps=False,
)
elif self.solver.__class__ in [PULP_CHOCO_CMD, CHOCO_CMD, MIPCL_CMD]:
elif self.solver.__class__ in [CHOCO_CMD, MIPCL_CMD]:
# this error is not detected with mps and choco, MIPCL_CMD can only use mps files
pass
else:
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_pulp_012(self):
elif self.solver.__class__ in [GUROBI_CMD, SCIP_CMD]:
# GUROBI_CMD has a very simple interface
pulpTestCheck(prob, self.solver, [const.LpStatusNotSolved])
elif self.solver.__class__ in [PULP_CHOCO_CMD, CHOCO_CMD]:
elif self.solver.__class__ in [CHOCO_CMD]:
# choco bounds all variables. Would not return unbounded status
pass
else:
Expand Down Expand Up @@ -217,7 +217,6 @@ def test_pulp_014(self):
CPLEX_PY,
GLPK_CMD,
GUROBI_CMD,
PULP_CHOCO_CMD,
CHOCO_CMD,
MIPCL_CMD,
MOSEK,
Expand Down Expand Up @@ -415,7 +414,6 @@ def test_pulp_030(self):
print("\t Testing MIP relaxation")
if self.solver.__class__ in [
GUROBI_CMD,
PULP_CHOCO_CMD,
CHOCO_CMD,
MIPCL_CMD,
SCIP_CMD,
Expand Down Expand Up @@ -755,7 +753,7 @@ def test_pulp_123(self):
elif self.solver.__class__ in [GUROBI_CMD, SCIP_CMD]:
# GLPK_CMD Does not report unbounded problems, correctly
pulpTestCheck(prob, self.solver, [const.LpStatusNotSolved])
elif self.solver.__class__ in [PULP_CHOCO_CMD, CHOCO_CMD]:
elif self.solver.__class__ in [CHOCO_CMD]:
# choco bounds all variables. Would not return unbounded status
pass
else:
Expand Down Expand Up @@ -944,7 +942,7 @@ def test_timeLimit(self):
self.solver.timeLimit = 20
# CHOCO has issues when given a time limit
print("\t Testing timeLimit argument")
if self.solver.name != "PULP_CHOCO_CMD":
if self.solver.name != "CHOCO_CMD":
pulpTestCheck(
prob,
self.solver,
Expand Down Expand Up @@ -1327,10 +1325,6 @@ class YAPOSIBTest(BaseSolverTest.PuLPTest):
solveInst = YAPOSIB


class PULP_CHOCO_CMDTest(BaseSolverTest.PuLPTest):
solveInst = PULP_CHOCO_CMD


class CHOCO_CMDTest(BaseSolverTest.PuLPTest):
solveInst = CHOCO_CMD

Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@
"pulp.solverdir.cbc.win.32",
"pulp.solverdir.cbc.win.64",
"pulp.solverdir.cbc.osx.64",
"pulp.solverdir.choco",
],
package_data={
"pulp.solverdir.cbc.linux.32": ["*", "*.*"],
"pulp.solverdir.cbc.linux.64": ["*", "*.*"],
"pulp.solverdir.cbc.win.32": ["*", "*.*"],
"pulp.solverdir.cbc.win.64": ["*", "*.*"],
"pulp.solverdir.cbc.osx.64": ["*", "*.*"],
"pulp.solverdir.choco": ["*", "*.*"],
},
include_package_data=True,
install_requires=[],
Expand Down

0 comments on commit 7b551d9

Please sign in to comment.