GurobiSolver: Accept integer variables, as long as bounds=(0,1)

master
Alinson S. Xavier 5 years ago
parent c4a6665825
commit 25affca3ec
No known key found for this signature in database
GPG Key ID: DCA0DAD4D2F58624

@ -476,12 +476,23 @@ class GurobiSolver(InternalSolver):
f"Unique variable names are currently required." f"Unique variable names are currently required."
) )
self._varname_to_var[var.varName] = var self._varname_to_var[var.varName] = var
assert var.vtype in ["B", "C"], ( vtype = var.vtype
if vtype == "I":
assert var.ub == 1.0, (
"Only binary and continuous variables are currently supported. "
"Integer variable {var.varName} has upper bound {var.ub}."
)
assert var.lb == 0.0, (
"Only binary and continuous variables are currently supported. "
"Integer variable {var.varName} has lower bound {var.ub}."
)
vtype = "B"
assert vtype in ["B", "C"], (
"Only binary and continuous variables are currently supported. " "Only binary and continuous variables are currently supported. "
"Variable {var.varName} has type {var.vtype}." "Variable {var.varName} has type {vtype}."
) )
self._original_vtype[var] = var.vtype self._original_vtype[var] = vtype
if var.vtype == "B": if vtype == "B":
self._bin_vars.append(var) self._bin_vars.append(var)
def __getstate__(self) -> Dict: def __getstate__(self) -> Dict:

Loading…
Cancel
Save