mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
pass needs ventilation to optimiser functon'
This commit is contained in:
parent
f79a17a056
commit
5305643991
2 changed files with 17 additions and 10 deletions
|
|
@ -1053,7 +1053,9 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
property_required_measures = [m for m in recommendations[p.id] if m[0]["type"] in body.required_measures]
|
||||
measures_to_optimise = [m for m in recommendations[p.id] if m[0]["type"] not in body.required_measures]
|
||||
|
||||
ventilation_included = "ventilation" in property_measure_types
|
||||
ventilation_included = (
|
||||
"ventilation" in property_measure_types or "mechanical_ventilation" in property_measure_types
|
||||
)
|
||||
|
||||
# If a measure requiring ventilation is selected, and the property does not have ventilation, we enfore
|
||||
# its inclusion
|
||||
|
|
@ -1177,8 +1179,10 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
recommendations=recommendations, selected=selected,
|
||||
)
|
||||
|
||||
# Add best practice measures (ventilation/trickle vents)
|
||||
selected = optimiser_functions.add_best_practice_measures(p.id, solution, recommendations, selected)
|
||||
# Add best practice measures (ventilation/trickle vents) - pass needs_ventilation flag
|
||||
selected = optimiser_functions.add_best_practice_measures(
|
||||
p.id, solution, recommendations, selected, needs_ventilation
|
||||
)
|
||||
# Final flattening - we pass what the battery SAP score would be, regardless if the battery was selected
|
||||
recommendations[p.id] = optimiser_functions.flatten_recommendations_with_defaults(
|
||||
p.id, recommendations, selected, battery_sap_score
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import pandas as pd
|
||||
from typing import List, Dict, Any, Set
|
||||
import backend.app.assumptions as assumptions
|
||||
from backend.Property import Property
|
||||
from backend.app.plan.schemas import PlanTriggerRequest
|
||||
|
|
@ -300,7 +301,13 @@ def add_required_measures(property_id, property_required_measures, recommendatio
|
|||
]
|
||||
|
||||
|
||||
def add_best_practice_measures(property_id, solution, recommendations, selected):
|
||||
def add_best_practice_measures(
|
||||
property_id: int,
|
||||
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
|
||||
in the selected recommendations when appropriate.
|
||||
|
|
@ -320,6 +327,8 @@ def add_best_practice_measures(property_id, solution, recommendations, selected)
|
|||
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
|
||||
-------
|
||||
|
|
@ -329,12 +338,6 @@ def add_best_practice_measures(property_id, solution, recommendations, selected)
|
|||
# Check if any selected measure requires ventilation
|
||||
ventilation_selected = [r for r in solution if "+mechanical_ventilation" in r["type"]]
|
||||
|
||||
# If ventilation has been selected, or one of the measures needs ventilation, we need to ensure ventilation is
|
||||
# included
|
||||
needs_ventilation = any(
|
||||
x in [r["type"] for r in solution] for x in assumptions.measures_needing_ventilation
|
||||
) or len(ventilation_selected) > 0
|
||||
|
||||
if needs_ventilation:
|
||||
ventilation_rec = next(
|
||||
(r[0] for r in recommendations[property_id] if r[0]["type"] == "mechanical_ventilation"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue