mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Move collected data to instance.training_data
This commit is contained in:
@@ -24,8 +24,8 @@ def test_convert_tight_usage():
|
||||
)
|
||||
|
||||
# Solve original problem
|
||||
solver.solve(instance)
|
||||
original_upper_bound = instance.upper_bound
|
||||
stats = solver.solve(instance)
|
||||
original_upper_bound = stats["Upper bound"]
|
||||
|
||||
# Should collect training data
|
||||
assert instance.training_data[0]["slacks"]["eq_capacity"] == 0.0
|
||||
@@ -35,12 +35,12 @@ def test_convert_tight_usage():
|
||||
stats = solver.solve(instance)
|
||||
|
||||
# Objective value should be the same
|
||||
assert instance.upper_bound == original_upper_bound
|
||||
assert stats["Upper bound"] == original_upper_bound
|
||||
assert stats["ConvertTight: Inf iterations"] == 0
|
||||
assert stats["ConvertTight: Subopt iterations"] == 0
|
||||
|
||||
|
||||
class TestInstance(Instance):
|
||||
class SampleInstance(Instance):
|
||||
def to_model(self):
|
||||
import gurobipy as grb
|
||||
|
||||
@@ -70,9 +70,9 @@ def test_convert_tight_infeasibility():
|
||||
components=[comp],
|
||||
solve_lp_first=False,
|
||||
)
|
||||
instance = TestInstance()
|
||||
instance = SampleInstance()
|
||||
stats = solver.solve(instance)
|
||||
assert instance.lower_bound == 5.0
|
||||
assert stats["Upper bound"] == 5.0
|
||||
assert stats["ConvertTight: Inf iterations"] == 1
|
||||
assert stats["ConvertTight: Subopt iterations"] == 0
|
||||
|
||||
@@ -93,9 +93,9 @@ def test_convert_tight_suboptimality():
|
||||
components=[comp],
|
||||
solve_lp_first=False,
|
||||
)
|
||||
instance = TestInstance()
|
||||
instance = SampleInstance()
|
||||
stats = solver.solve(instance)
|
||||
assert instance.lower_bound == 5.0
|
||||
assert stats["Upper bound"] == 5.0
|
||||
assert stats["ConvertTight: Inf iterations"] == 0
|
||||
assert stats["ConvertTight: Subopt iterations"] == 1
|
||||
|
||||
@@ -116,8 +116,8 @@ def test_convert_tight_optimal():
|
||||
components=[comp],
|
||||
solve_lp_first=False,
|
||||
)
|
||||
instance = TestInstance()
|
||||
instance = SampleInstance()
|
||||
stats = solver.solve(instance)
|
||||
assert instance.lower_bound == 5.0
|
||||
assert stats["Upper bound"] == 5.0
|
||||
assert stats["ConvertTight: Inf iterations"] == 0
|
||||
assert stats["ConvertTight: Subopt iterations"] == 0
|
||||
|
||||
Reference in New Issue
Block a user