Model/recommendations/optimiser/optimiser_functions.py
Khalim Conn-Kowlessar 4e41993455 savings
2024-04-10 17:20:49 +01:00

37 lines
1.3 KiB
Python

def prepare_input_measures(property_recommendations, goal, housing_type):
"""
Basic function to convert recommendations_to_upload to a format that is
suitable for the optimiser - large
:param property_recommendations: object containing the recommendations, created in the plan trigger api
:param goal: goal to be optimised for, should be one of the keys in gain_map. E.g. if the gain is SAP points,
the goal should reflect that desired gain
:param housing_type: type of housing the recommendations are for - should be one of "Social" or "Private"
:return: Nested list of input measures
"""
if housing_type not in ["Social", "Private"]:
raise ValueError("Invalid housing type - investigate me")
goal_map = {
"Increase EPC": "sap_points"
}
goal_key = goal_map[goal]
if not goal_key:
raise NotImplementedError("Not implemented this gain type - investigate me")
input_measures = []
for recs in property_recommendations:
input_measures.append(
[
{
"id": rec["recommendation_id"],
"cost": rec["total"],
"gain": rec[goal_key],
"type": rec["type"]
}
for rec in recs
]
)
return input_measures