Move collected data to instance.training_data

This commit is contained in:
2021-01-21 08:21:40 -06:00
parent 23dd311d75
commit 06402516e6
11 changed files with 97 additions and 89 deletions

View File

@@ -15,8 +15,8 @@ def test_stab():
weights = [1.0, 1.0, 1.0, 1.0, 1.0]
instance = MaxWeightStableSetInstance(graph, weights)
solver = LearningSolver()
solver.solve(instance)
assert instance.lower_bound == 2.0
stats = solver.solve(instance)
assert stats["Lower bound"] == 2.0
def test_stab_generator_fixed_graph():

View File

@@ -38,16 +38,16 @@ def test_instance():
)
instance = TravelingSalesmanInstance(n_cities, distances)
solver = LearningSolver()
solver.solve(instance)
x = instance.solution["x"]
stats = solver.solve(instance)
x = instance.training_data[0]["Solution"]["x"]
assert x[0, 1] == 1.0
assert x[0, 2] == 0.0
assert x[0, 3] == 1.0
assert x[1, 2] == 1.0
assert x[1, 3] == 0.0
assert x[2, 3] == 1.0
assert instance.lower_bound == 4.0
assert instance.upper_bound == 4.0
assert stats["Lower bound"] == 4.0
assert stats["Upper bound"] == 4.0
def test_subtour():
@@ -68,7 +68,7 @@ def test_subtour():
solver.solve(instance)
assert hasattr(instance, "found_violated_lazy_constraints")
assert hasattr(instance, "found_violated_user_cuts")
x = instance.solution["x"]
x = instance.training_data[0]["Solution"]["x"]
assert x[0, 1] == 1.0
assert x[0, 4] == 1.0
assert x[1, 2] == 1.0