Skip to content

Commit

Permalink
More robust testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao-Dionisio committed Oct 18, 2024
1 parent 1e5a56f commit 53627d2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_recipe_primal_dual_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,20 @@ def test_primal_dual_evolution():

# these are required because the event handler doesn't capture the final state
model.data["primal_solutions"].append((model.getSolvingTime(), model.getPrimalbound()))
model.data["dual_solutions"].append((model.getSolvingTime(), model.getDualbound()))
model.data["dual_solutions"].append((model.getSolvingTime(), model.getDualbound()))

for i in range(1, len(model.data["primal_solutions"])):
if model.getObjectiveSense() == "minimize":
assert model.data["primal_solutions"][i][1] <= model.data["primal_solutions"][i-1][1]
else:
assert model.data["primal_solutions"][i][1] >= model.data["primal_solutions"][i-1][1]

for i in range(1, len(model.data["dual_solutions"])):
if model.getObjectiveSense() == "minimize":
assert model.data["dual_solutions"][i][1] >= model.data["dual_solutions"][i-1][1]
else:
assert model.data["dual_solutions"][i][1] <= model.data["dual_solutions"][i-1][1]

# how to get a simple plot of the data
#from pyscipopt.recipes.primal_dual_evolution import plot_primal_dual_evolution
#plot_primal_dual_evolution(model)

0 comments on commit 53627d2

Please sign in to comment.