Add XpressPyomoSolver

This commit is contained in:
2021-01-19 22:27:57 -06:00
parent 34e1711081
commit 4b8672870a
6 changed files with 77 additions and 15 deletions

View File

@@ -0,0 +1,34 @@
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
import sys
import logging
from io import StringIO
from pyomo import environ as pe
from scipy.stats import randint
from .base import BasePyomoSolver
from .. import RedirectOutput
logger = logging.getLogger(__name__)
class XpressPyomoSolver(BasePyomoSolver):
"""
An InternalSolver that uses XPRESS and the Pyomo modeling language.
Parameters
----------
params: dict
Dictionary of options to pass to the Pyomo solver. For example,
{"Threads": 4} to set the number of threads.
"""
def __init__(self, params=None):
super().__init__(
solver_factory=pe.SolverFactory("xpress_persistent"),
params={
"randomseed": randint(low=0, high=1000).rvs(),
},
)