Minor changes to docstrings

This commit is contained in:
2021-01-07 10:08:14 -06:00
parent 191da25cfc
commit 0377b5b546
2 changed files with 45 additions and 41 deletions

View File

@@ -6,6 +6,10 @@
class Component: class Component:
""" """
A Component is an object which adds functionality to a LearningSolver. A Component is an object which adds functionality to a LearningSolver.
For better code maintainability, LearningSolver simply delegates most of its
functionality to Components. Each Component is responsible for exactly one ML
strategy.
""" """
def before_solve(self, solver, instance, model): def before_solve(self, solver, instance, model):

View File

@@ -23,7 +23,6 @@ from .pyomo.gurobi import GurobiPyomoSolver
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Global memory for multiprocessing # Global memory for multiprocessing
SOLVER = [None] # type: List[Optional[LearningSolver]] SOLVER = [None] # type: List[Optional[LearningSolver]]
INSTANCES = [None] # type: List[Optional[dict]] INSTANCES = [None] # type: List[Optional[dict]]
@@ -45,18 +44,6 @@ def _parallel_solve(idx):
class LearningSolver: class LearningSolver:
def __init__(
self,
components=None,
gap_tolerance=1e-4,
mode="exact",
solver="gurobi",
threads=None,
time_limit=None,
node_limit=None,
solve_lp_first=True,
use_lazy_cb=False,
):
""" """
Mixed-Integer Linear Programming (MIP) solver that extracts information Mixed-Integer Linear Programming (MIP) solver that extracts information
from previous runs and uses Machine Learning methods to accelerate the from previous runs and uses Machine Learning methods to accelerate the
@@ -75,7 +62,7 @@ class LearningSolver:
mode mode
If "exact", solves problem to optimality, keeping all optimality If "exact", solves problem to optimality, keeping all optimality
guarantees provided by the MIP solver. If "heuristic", uses machine guarantees provided by the MIP solver. If "heuristic", uses machine
learning more agressively, and may return suboptimal solutions. learning more aggressively, and may return suboptimal solutions.
solver solver
The internal MIP solver to use. Can be either "cplex", "gurobi", a The internal MIP solver to use. Can be either "cplex", "gurobi", a
solver class such as GurobiSolver, or a solver instance such as solver class such as GurobiSolver, or a solver instance such as
@@ -97,6 +84,19 @@ class LearningSolver:
expensive to solve and if it provides good hints for the integer expensive to solve and if it provides good hints for the integer
solution. solution.
""" """
def __init__(
self,
components=None,
gap_tolerance=1e-4,
mode="exact",
solver="gurobi",
threads=None,
time_limit=None,
node_limit=None,
solve_lp_first=True,
use_lazy_cb=False,
):
self.components = {} self.components = {}
self.mode = mode self.mode = mode
self.internal_solver = None self.internal_solver = None