mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-08 10:28:52 -06:00
Initial version
This commit is contained in:
25
miplearn/solvers.py
Normal file
25
miplearn/solvers.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# MIPLearn: A Machine-Learning Framework for Mixed-Integer Optimization
|
||||
# Copyright (C) 2019-2020 Argonne National Laboratory. All rights reserved.
|
||||
# Written by Alinson S. Xavier <axavier@anl.gov>
|
||||
|
||||
import pyomo.environ as pe
|
||||
|
||||
class LearningSolver:
|
||||
"""
|
||||
LearningSolver is a Mixed-Integer Linear Programming (MIP) solver that uses information from
|
||||
previous runs to accelerate the solution of new, unseen instances.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.parent_solver = pe.SolverFactory('cplex_persistent')
|
||||
self.parent_solver.options["threads"] = 4
|
||||
|
||||
def solve(self, params):
|
||||
"""
|
||||
Solve the optimization problem represented by the given parameters.
|
||||
The parameters and the obtained solution is recorded.
|
||||
"""
|
||||
model = params.to_model()
|
||||
self.parent_solver.set_instance(model)
|
||||
self.parent_solver.solve(tee=True)
|
||||
|
||||
Reference in New Issue
Block a user