Use compact variable features everywhere

This commit is contained in:
2021-04-15 09:49:35 -05:00
parent fec0113722
commit 95e326f5f6
11 changed files with 147 additions and 374 deletions

View File

@@ -43,13 +43,8 @@ def test_instance() -> None:
assert instance.samples[0].after_mip is not None
features = instance.samples[0].after_mip
assert features is not None
assert features.variables_old is not None
assert features.variables_old["x[(0, 1)]"].value == 1.0
assert features.variables_old["x[(0, 2)]"].value == 0.0
assert features.variables_old["x[(0, 3)]"].value == 1.0
assert features.variables_old["x[(1, 2)]"].value == 1.0
assert features.variables_old["x[(1, 3)]"].value == 0.0
assert features.variables_old["x[(2, 3)]"].value == 1.0
assert features.variables is not None
assert features.variables.values == (1.0, 0.0, 1.0, 1.0, 0.0, 1.0)
assert features.mip_solve is not None
assert features.mip_solve.mip_lower_bound == 4.0
assert features.mip_solve.mip_upper_bound == 4.0
@@ -79,12 +74,23 @@ def test_subtour() -> None:
lazy_enforced = features.extra["lazy_enforced"]
assert lazy_enforced is not None
assert len(lazy_enforced) > 0
assert features.variables_old is not None
assert features.variables_old["x[(0, 1)]"].value == 1.0
assert features.variables_old["x[(0, 4)]"].value == 1.0
assert features.variables_old["x[(1, 2)]"].value == 1.0
assert features.variables_old["x[(2, 3)]"].value == 1.0
assert features.variables_old["x[(3, 5)]"].value == 1.0
assert features.variables_old["x[(4, 5)]"].value == 1.0
assert features.variables is not None
assert features.variables.values == (
1.0,
0.0,
0.0,
1.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
1.0,
)
solver.fit([instance])
solver.solve(instance)