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

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

@ -284,7 +284,13 @@ class LearningSolver:
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.
@ -295,6 +301,12 @@ class LearningSolver:
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]
The instances to be solved
n_jobs: int
@ -308,6 +320,8 @@ class LearningSolver:
[solver.solve(p) for p in instances]
"""
if output is None:
output = []
self.internal_solver = None
self._silence_miplearn_logger()
SOLVER[0] = self

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

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

Loading…
Cancel
Save