File tree Expand file tree Collapse file tree 2 files changed +5
-24
lines changed Expand file tree Collapse file tree 2 files changed +5
-24
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,7 @@ def solve(self):
11
11
12
12
13
13
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."""
23
15
24
16
def __init__ (self , name ):
25
17
"""Initialize.
@@ -29,23 +21,12 @@ def __init__(self, name):
29
21
name : str
30
22
The desired name for the model.
31
23
"""
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
-
44
24
self .name = name
45
25
26
+ @abstractmethod
46
27
def solve (self ):
47
28
"""Solve the optimization model."""
48
- self . spOptSolver . Solve ()
29
+ pass
49
30
50
31
51
32
class BaseSpOptHeuristicSolver (BaseSpOptSolver ):
Original file line number Diff line number Diff line change 1
1
from abc import abstractmethod
2
2
3
- from ..BaseClass import BaseSpOptSolver
3
+ from ..BaseClass import BaseSpOptExactSolver
4
4
from typing import TypeVar
5
5
6
6
import numpy as np
17
17
}
18
18
19
19
20
- class LocateSolver (BaseSpOptSolver ):
20
+ class LocateSolver (BaseSpOptExactSolver ):
21
21
"""Base class for the ``locate`` package."""
22
22
23
23
def __init__ (self , name : str , problem : pulp .LpProblem ):
You can’t perform that action at this time.
0 commit comments