mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-07 01:48:51 -06:00
ConstraintFeatures: Store lhs and sense
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
# 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.
|
||||
|
||||
from miplearn import GurobiSolver
|
||||
from miplearn.features import ModelFeaturesExtractor
|
||||
from tests.fixtures.knapsack import get_knapsack_instance
|
||||
from tests.solvers import get_internal_solvers
|
||||
|
||||
|
||||
def test_knapsack() -> None:
|
||||
for solver_factory in get_internal_solvers():
|
||||
for solver_factory in [GurobiSolver]:
|
||||
# Initialize model, instance and internal solver
|
||||
solver = solver_factory()
|
||||
instance = get_knapsack_instance(solver)
|
||||
@@ -20,4 +21,11 @@ def test_knapsack() -> None:
|
||||
|
||||
# Test constraint features
|
||||
print(solver, features)
|
||||
assert features["ConstraintRHS"]["eq_capacity"] == 67.0
|
||||
assert features["constraints"]["eq_capacity"]["lhs"] == {
|
||||
"x[0]": 23.0,
|
||||
"x[1]": 26.0,
|
||||
"x[2]": 20.0,
|
||||
"x[3]": 18.0,
|
||||
}
|
||||
assert features["constraints"]["eq_capacity"]["sense"] == "<"
|
||||
assert features["constraints"]["eq_capacity"]["rhs"] == 67.0
|
||||
|
||||
Reference in New Issue
Block a user