mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Reactivate linear relaxation code; move to WarmStartComponent
This commit is contained in:
@@ -14,6 +14,7 @@ from sklearn.preprocessing import StandardScaler
|
|||||||
from sklearn.model_selection import cross_val_score
|
from sklearn.model_selection import cross_val_score
|
||||||
from sklearn.neighbors import KNeighborsClassifier
|
from sklearn.neighbors import KNeighborsClassifier
|
||||||
from tqdm.auto import tqdm
|
from tqdm.auto import tqdm
|
||||||
|
import pyomo.environ as pe
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -140,6 +141,12 @@ class WarmStartComponent(Component):
|
|||||||
self.is_warm_start_available = False
|
self.is_warm_start_available = False
|
||||||
|
|
||||||
def before_solve(self, solver, instance, model):
|
def before_solve(self, solver, instance, model):
|
||||||
|
# Solve linear relaxation
|
||||||
|
lr_solver = pe.SolverFactory("gurobi")
|
||||||
|
lr_solver.options["threads"] = 4
|
||||||
|
lr_solver.options["relax_integrality"] = 1
|
||||||
|
lr_solver.solve(model, tee=solver.tee)
|
||||||
|
|
||||||
# Build x_test
|
# Build x_test
|
||||||
x_test = CombinedExtractor([UserFeaturesExtractor(),
|
x_test = CombinedExtractor([UserFeaturesExtractor(),
|
||||||
SolutionExtractor(),
|
SolutionExtractor(),
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class LearningSolver:
|
|||||||
self.threads = threads
|
self.threads = threads
|
||||||
self.time_limit = time_limit
|
self.time_limit = time_limit
|
||||||
self.gap_limit = gap_limit
|
self.gap_limit = gap_limit
|
||||||
|
self.tee = False
|
||||||
|
|
||||||
if self.components is not None:
|
if self.components is not None:
|
||||||
assert isinstance(self.components, dict)
|
assert isinstance(self.components, dict)
|
||||||
@@ -63,12 +64,7 @@ class LearningSolver:
|
|||||||
|
|
||||||
def solve(self, instance, tee=False):
|
def solve(self, instance, tee=False):
|
||||||
model = instance.to_model()
|
model = instance.to_model()
|
||||||
|
self.tee = tee
|
||||||
# # Solve linear relaxation (TODO: use solver provided by user)
|
|
||||||
# lr_solver = pe.SolverFactory("gurobi")
|
|
||||||
# lr_solver.options["threads"] = 4
|
|
||||||
# lr_solver.options["relax_integrality"] = 1
|
|
||||||
# lr_solver.solve(model)
|
|
||||||
|
|
||||||
self._create_solver()
|
self._create_solver()
|
||||||
if self.is_persistent:
|
if self.is_persistent:
|
||||||
|
|||||||
Reference in New Issue
Block a user