mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
handle the case of not requiring any measures
This commit is contained in:
parent
b3f8a9dccc
commit
23b62b0c54
1 changed files with 7 additions and 1 deletions
|
|
@ -857,6 +857,9 @@ async def build_mds(body: MdsRequest):
|
|||
carbon_prediction["row_id"] = carbon_prediction.index
|
||||
|
||||
epc_target = body.goal_value
|
||||
if epc_before == epc_target:
|
||||
continue
|
||||
|
||||
sap_target = epc_to_sap_lower_bound(epc_target)
|
||||
# Define the measures
|
||||
sap_threshold_barrier = sap_prediction[sap_prediction["predictions"] >= sap_target]
|
||||
|
|
@ -934,10 +937,13 @@ async def build_mds(body: MdsRequest):
|
|||
if not package_comparison.empty:
|
||||
|
||||
# We check if any of the packages meet the threshold
|
||||
# If none of them do, take the one that gets closest to the target
|
||||
if package_comparison["meets_threshold"].any():
|
||||
package_comparison = package_comparison[package_comparison["meets_threshold"]]
|
||||
package_comparison = package_comparison.sort_values("cost")
|
||||
else:
|
||||
package_comparison = package_comparison.sort_values("sap_after", ascending=False)
|
||||
|
||||
package_comparison = package_comparison.sort_values("cost")
|
||||
package_comparison = package_comparison.head(1).to_dict("records")[0]
|
||||
else:
|
||||
package_comparison = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue