Skip to content

Commit b4044bb

Browse files
authored
Merge pull request #305 from jGaboardi/remove_ortools
utilize `BaseSpOptExactSolver`
2 parents 21fe3e0 + a0e8465 commit b4044bb

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

spopt/BaseClass.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ def solve(self):
1111

1212

1313
class BaseSpOptExactSolver(BaseSpOptSolver):
14-
"""Base class for all spatial optimization model exact solvers.
15-
16-
Attributes
17-
----------
18-
19-
spOptSolver : pywraplp.Solver
20-
The or-tools MIP solver.
21-
22-
"""
14+
"""Base class for all spatial optimization model exact solvers."""
2315

2416
def __init__(self, name):
2517
"""Initialize.
@@ -29,23 +21,12 @@ def __init__(self, name):
2921
name : str
3022
The desired name for the model.
3123
"""
32-
try:
33-
from ortools.linear_solver import pywraplp
34-
35-
self.spOptSolver = pywraplp.Solver(
36-
name, pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING
37-
)
38-
except ImportError:
39-
raise ImportError(
40-
"ortools is a requirement for exact solvers. "
41-
"you can install it with `pip install ortools`"
42-
)
43-
4424
self.name = name
4525

26+
@abstractmethod
4627
def solve(self):
4728
"""Solve the optimization model."""
48-
self.spOptSolver.Solve()
29+
pass
4930

5031

5132
class BaseSpOptHeuristicSolver(BaseSpOptSolver):

spopt/locate/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import abstractmethod
22

3-
from ..BaseClass import BaseSpOptSolver
3+
from ..BaseClass import BaseSpOptExactSolver
44
from typing import TypeVar
55

66
import numpy as np
@@ -17,7 +17,7 @@
1717
}
1818

1919

20-
class LocateSolver(BaseSpOptSolver):
20+
class LocateSolver(BaseSpOptExactSolver):
2121
"""Base class for the ``locate`` package."""
2222

2323
def __init__(self, name: str, problem: pulp.LpProblem):

0 commit comments

Comments
 (0)