mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
handling the case of there not being any suitable recommendations for a property
This commit is contained in:
parent
852420a8fa
commit
110f461d49
2 changed files with 45 additions and 28 deletions
|
|
@ -1043,6 +1043,15 @@ async def model_engine(body: PlanTriggerRequest):
|
||||||
work_package=eco_packages[p.id][2]
|
work_package=eco_packages[p.id][2]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if handle the empty case
|
||||||
|
if solutions.empty:
|
||||||
|
scheme = "none"
|
||||||
|
funded_measures, solution = [], []
|
||||||
|
(
|
||||||
|
project_funding, total_uplift, full_project_score, partial_project_score, uplift_project_score
|
||||||
|
) = 0, 0, 0, 0, 0
|
||||||
|
else:
|
||||||
|
|
||||||
# If the solution isn't eligible, we can't really consider it
|
# If the solution isn't eligible, we can't really consider it
|
||||||
solutions = solutions[
|
solutions = solutions[
|
||||||
(solutions["is_eligible"] & (solutions["scheme"] != "none")) | (solutions["scheme"] == "none")
|
(solutions["is_eligible"] & (solutions["scheme"] != "none")) | (solutions["scheme"] == "none")
|
||||||
|
|
|
||||||
|
|
@ -502,6 +502,10 @@ def optimise_with_funding_paths(
|
||||||
|
|
||||||
solutions = pd.DataFrame(solutions)
|
solutions = pd.DataFrame(solutions)
|
||||||
|
|
||||||
|
if solutions.empty:
|
||||||
|
# We return a blank dataframe
|
||||||
|
return solutions
|
||||||
|
|
||||||
# Given the scheme, we now check if the packages are eligible. If they *are* eligible, but they don't meet the
|
# Given the scheme, we now check if the packages are eligible. If they *are* eligible, but they don't meet the
|
||||||
# final upgrade target, we then look to perform a final optimisation pass to meet the target gain.
|
# final upgrade target, we then look to perform a final optimisation pass to meet the target gain.
|
||||||
solutions["meets_upgrade_target"] = solutions["total_gain"] >= target_gain - 0.1
|
solutions["meets_upgrade_target"] = solutions["total_gain"] >= target_gain - 0.1
|
||||||
|
|
@ -779,6 +783,10 @@ def run_optimizer(input_measures, budget=None, sub_target_gain=None, allow_slack
|
||||||
Thin wrapper over your optimisers.
|
Thin wrapper over your optimisers.
|
||||||
Returns: list[dict] selected_options
|
Returns: list[dict] selected_options
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not input_measures:
|
||||||
|
return None, 0.0, 0.0
|
||||||
|
|
||||||
if budget is not None:
|
if budget is not None:
|
||||||
opt = GainOptimiser(
|
opt = GainOptimiser(
|
||||||
input_measures, max_cost=budget, max_gain=(sub_target_gain or float("inf")),
|
input_measures, max_cost=budget, max_gain=(sub_target_gain or float("inf")),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue