Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliette-Gerbaux committed Aug 21, 2024
1 parent b4790ce commit 35a2f64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def test_milp_version(
assert resolution_step.solver.Objective().Value() == pytest.approx(
expected_cost[scenario][week]
)
assert sum(
OutputValues(resolution_step)
.component("S")
.var("spillage")
.value[0] # type:ignore
) == pytest.approx(15884)


def test_accurate_heuristic(
Expand Down Expand Up @@ -207,6 +213,12 @@ def test_accurate_heuristic(
assert resolution_step_2.solver.Objective().Value() == pytest.approx(
expected_cost[scenario][week]
)
assert sum(
OutputValues(resolution_step_2)
.component("S")
.var("spillage")
.value[0] # type:ignore
) == pytest.approx(22191)


def test_fast_heuristic(
Expand Down Expand Up @@ -314,3 +326,9 @@ def test_fast_heuristic(
assert resolution_step_2.solver.Objective().Value() == pytest.approx(
expected_cost[scenario][week]
)
assert sum(
OutputValues(resolution_step_2)
.component("S")
.var("spillage")
.value[0] # type:ignore
) == pytest.approx(255873)
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_milp_version(
time_scenario_parameters: TimeScenarioHourParameter,
) -> None:
"""Solve weekly problem with two clusters and a binding constraint between these two clusters.
The optimal solution consists in turning on the first unit all the and the second unit which is more expensive but more flexible when the load increases at the 13th timestep.
The optimal solution consists in turning on the first unit all the time and in turning on the second unit, which is more expensive but more flexible, when the load increases at the 13th timestep.
"""
network = get_network(
input_components,
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_milp_version(
output_idx=ExpectedOutputIndexes(
idx_generation=4, idx_nodu=6, idx_spillage=29, idx_unsupplied=25
),
)
) # On/off values of clusters are checked in expected_output
expected_output.check_output_values(OutputValues(main_resolution_step))


Expand Down Expand Up @@ -172,7 +172,7 @@ def test_accurate_heuristic(
time_scenario_parameters: TimeScenarioHourParameter,
) -> None:
"""
Solve the same problem as before with the heuristic accurate of Antares. The accurate heuristic decides to turn on 3 units of the first cluster but due to the binding constraint and p_min, the problem become infeasible.
Solve the same problem as before with the heuristic accurate of Antares. The accurate heuristic decides to turn on 3 units of the first cluster but due to the binding constraint and p_min, the problem becomes infeasible.
"""

number_hours = 168
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_fast_heuristic(
heuristic_components: List[str],
time_scenario_parameters: TimeScenarioHourParameter,
) -> None:
"""Solve the same problem as before with the heuristic fast of Antares. The fast heuristic decides to turn on 3 units of the first cluster but due to the binding constraint and p_min, the problem become infeasible."""
"""Solve the same problem as before with the heuristic fast of Antares. The fast heuristic decides to turn on 3 units of the first cluster but due to the binding constraint and p_min, the problem becomes infeasible."""

number_hours = 168

Expand Down

0 comments on commit 35a2f64

Please sign in to comment.