diff --git a/.idea/Model.iml b/.idea/Model.iml
index e1ca1b70..c6561970 100644
--- a/.idea/Model.iml
+++ b/.idea/Model.iml
@@ -7,7 +7,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index b1ee5ffa..50cad4ca 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/recommendations/optimiser/optimiser_functions.py b/recommendations/optimiser/optimiser_functions.py
index a5cbf90d..6fd70c20 100644
--- a/recommendations/optimiser/optimiser_functions.py
+++ b/recommendations/optimiser/optimiser_functions.py
@@ -306,7 +306,6 @@ def add_best_practice_measures(
solution: List[Dict[str, Any]],
recommendations: Dict[int, List[List[Dict[str, Any]]]],
selected: Set[str],
- needs_ventilation: bool
):
"""
Ensures best-practice measures like ventilation and trickle vents are included
@@ -327,8 +326,6 @@ def add_best_practice_measures(
All recommendations for all properties, keyed by property id.
selected : set
Set of already selected recommendation IDs.
- needs_ventilation : bool
- Whether the property requires mechanical ventilation to accompany certain measures.
Returns
-------
@@ -338,7 +335,13 @@ def add_best_practice_measures(
# Check if any selected measure requires ventilation
ventilation_selected = [r for r in solution if "+mechanical_ventilation" in r["type"]]
- if needs_ventilation:
+ # If ventilation has been selected, or one of the measures needs ventilation, we need to ensure ventilation is
+ # included
+ measures_selected_needing_ventilation = any(
+ x in [r["type"] for r in solution] for x in assumptions.measures_needing_ventilation
+ )
+
+ if measures_selected_needing_ventilation or len(ventilation_selected) > 0:
ventilation_rec = next(
(r[0] for r in recommendations[property_id] if r[0]["type"] == "mechanical_ventilation"),
None
diff --git a/recommendations/tests/test_optimiser_functions.py b/recommendations/tests/test_optimiser_functions.py
index 08541c21..0a31ae2c 100644
--- a/recommendations/tests/test_optimiser_functions.py
+++ b/recommendations/tests/test_optimiser_functions.py
@@ -155,7 +155,7 @@ class TestAddBestPracticeMeasures:
}
selected = set()
updated = optimiser_functions.add_best_practice_measures(
- property_id, solution, recommendations, selected, True
+ property_id, solution, recommendations, selected
)
assert "vent1" in updated
assert "trickle1" in updated
@@ -286,7 +286,7 @@ class TestIncreasingEpcE2e:
total_optimised_gain = sum(m["gain"] for m in solution)
assert total_optimised_gain == 17.6, "Total gain of optimised measures should meet or exceed target gain"
- selected = optimiser_functions.add_best_practice_measures(p.id, solution, recommendations, selected, False)
+ selected = optimiser_functions.add_best_practice_measures(p.id, solution, recommendations, selected)
# Flatten recommendations for output
flattened = optimiser_functions.flatten_recommendations_with_defaults(p.id, recommendations, selected)