Fix various warnings

master
Alinson S. Xavier 5 years ago
parent 36061d5a14
commit a536d2ecc6

@ -41,11 +41,11 @@ class RelaxationComponent(Component):
If a constraint has slack greater than this threshold, then the constraint is If a constraint has slack greater than this threshold, then the constraint is
considered loose. By default, this threshold equals a small positive number to considered loose. By default, this threshold equals a small positive number to
compensate for numerical issues. compensate for numerical issues.
check_dropped : bool, optional check_feasibility : bool, optional
If `check_dropped` is true, then, after the problem is solved, the component If true, after the problem is solved, the component verifies that all dropped
verifies that all dropped constraints are still satisfied, re-adds the violated constraints are still satisfied, re-adds the violated ones and resolves the
ones and resolves the problem. This loop continues until either no violations problem. This loop continues until either no violations are found, or a maximum
are found, or a maximum number of iterations is reached. number of iterations is reached.
violation_tolerance : float, optional violation_tolerance : float, optional
If `check_dropped` is true, a constraint is considered satisfied during the If `check_dropped` is true, a constraint is considered satisfied during the
check if its violation is smaller than this tolerance. check if its violation is smaller than this tolerance.
@ -61,7 +61,7 @@ class RelaxationComponent(Component):
tight_classifier=CountingClassifier(), tight_classifier=CountingClassifier(),
tight_threshold=0.95, tight_threshold=0.95,
slack_tolerance=1e-5, slack_tolerance=1e-5,
check_dropped=False, check_feasibility=False,
violation_tolerance=1e-5, violation_tolerance=1e-5,
max_check_iterations=3, max_check_iterations=3,
): ):
@ -73,7 +73,7 @@ class RelaxationComponent(Component):
slack_tolerance=slack_tolerance, slack_tolerance=slack_tolerance,
violation_tolerance=violation_tolerance, violation_tolerance=violation_tolerance,
max_iterations=max_check_iterations, max_iterations=max_check_iterations,
check_dropped=check_dropped, check_feasibility=check_feasibility,
), ),
ConvertTightIneqsIntoEqsStep( ConvertTightIneqsIntoEqsStep(
classifier=tight_classifier, classifier=tight_classifier,
@ -86,8 +86,8 @@ class RelaxationComponent(Component):
def before_solve(self, solver, instance, model): def before_solve(self, solver, instance, model):
self.composite.before_solve(solver, instance, model) self.composite.before_solve(solver, instance, model)
def after_solve(self, solver, instance, model, results): def after_solve(self, solver, instance, model, stats, training_data):
self.composite.after_solve(solver, instance, model, results) self.composite.after_solve(solver, instance, model, stats, training_data)
def fit(self, training_instances): def fit(self, training_instances):
self.composite.fit(training_instances) self.composite.fit(training_instances)

@ -8,8 +8,9 @@ import time
import sys import sys
class TimeFormatter: class TimeFormatter(logging.Formatter):
def __init__(self, start_time, log_colors): def __init__(self, start_time, log_colors):
super().__init__()
self.start_time = start_time self.start_time = start_time
self.log_colors = log_colors self.log_colors = log_colors

@ -284,7 +284,13 @@ class LearningSolver:
return stats return stats
def parallel_solve(self, instances, n_jobs=4, label="Solve", output=[]): def parallel_solve(
self,
instances,
n_jobs=4,
label="Solve",
output=None,
):
""" """
Solves multiple instances in parallel. Solves multiple instances in parallel.
@ -295,6 +301,12 @@ class LearningSolver:
Parameters Parameters
---------- ----------
output: [str] or None
If instances are file names and output is provided, write the modified
instances to these files, instead of replacing the original files. If
output is None, discard modified instance.
label: str
Label to show in the progress bar.
instances: [miplearn.Instance] or [str] instances: [miplearn.Instance] or [str]
The instances to be solved The instances to be solved
n_jobs: int n_jobs: int
@ -308,6 +320,8 @@ class LearningSolver:
[solver.solve(p) for p in instances] [solver.solve(p) for p in instances]
""" """
if output is None:
output = []
self.internal_solver = None self.internal_solver = None
self._silence_miplearn_logger() self._silence_miplearn_logger()
SOLVER[0] = self SOLVER[0] = self

@ -2,12 +2,12 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved. # Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details. # Released under the modified BSD license. See COPYING.md for more details.
import logging
import re import re
import sys import sys
import logging
import pyomo
from abc import abstractmethod
from io import StringIO from io import StringIO
import pyomo
from pyomo import environ as pe from pyomo import environ as pe
from pyomo.core import Var, Constraint from pyomo.core import Var, Constraint

@ -14,3 +14,4 @@ scikit-learn~=0.23
tqdm~=4.54 tqdm~=4.54
black==20.8b1 black==20.8b1
pre-commit~=2.9 pre-commit~=2.9
scipy~=1.6.0

Loading…
Cancel
Save