mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
added upgrade eligibility check for optimisation
This commit is contained in:
parent
b73525e571
commit
06e8204404
1 changed files with 23 additions and 2 deletions
|
|
@ -779,12 +779,24 @@ def _filter_measures_by_types(input_measures, allowed_types):
|
|||
return filtered
|
||||
|
||||
|
||||
def optimise_with_funding_paths(input_measures, budget=None, target_gain=None, social=False):
|
||||
def _is_eligible_funding_package(scheme, starting_sap, total_gain):
|
||||
if scheme == "eco4":
|
||||
# We check if we meet the upgrade requirements
|
||||
# If the property is an E or above, we need to upgrade to a C or above
|
||||
if starting_sap >= 39: # ie. EPC C or above
|
||||
return starting_sap + total_gain >= 69
|
||||
|
||||
if scheme == "gbis":
|
||||
# GBIS is a fixed measure only, so we don't check the gain
|
||||
return True
|
||||
|
||||
|
||||
def optimise_with_funding_paths(p, input_measures, housing_type, budget=None, target_gain=None):
|
||||
"""
|
||||
run_optimizer(sub_measures, budget, target_gain) -> (picked_options, sub_cost, sub_gain)
|
||||
"""
|
||||
|
||||
funding_paths = make_funding_paths(p, input_measures, body.housing_type)
|
||||
funding_paths = make_funding_paths(p, input_measures, housing_type)
|
||||
|
||||
# We now produce a fabric only path for ECO4
|
||||
# We add in generic insulation funding paths (where there is no fixed measure)
|
||||
|
|
@ -811,6 +823,8 @@ def optimise_with_funding_paths(input_measures, budget=None, target_gain=None, s
|
|||
if picked is None:
|
||||
continue
|
||||
|
||||
scheme = _path_scheme([path_spec])
|
||||
|
||||
solutions.append(
|
||||
{
|
||||
"fixed_ids": [],
|
||||
|
|
@ -818,8 +832,11 @@ def optimise_with_funding_paths(input_measures, budget=None, target_gain=None, s
|
|||
"total_cost": sub_cost,
|
||||
"total_gain": sub_gain,
|
||||
"path": path_spec,
|
||||
"scheme": scheme,
|
||||
"is_eligible": _is_eligible_funding_package(scheme, p.data["current-energy-efficiency"], sub_gain)
|
||||
}
|
||||
)
|
||||
|
||||
continue
|
||||
|
||||
# 1) expand fixed selections for this path
|
||||
|
|
@ -872,12 +889,16 @@ def optimise_with_funding_paths(input_measures, budget=None, target_gain=None, s
|
|||
total_gain = fixed_gain + sub_gain
|
||||
total_picks = fixed_items + picked
|
||||
|
||||
scheme = _path_scheme(path_spec)
|
||||
|
||||
solutions.append({
|
||||
"fixed_ids": fixed_ids,
|
||||
"items": total_picks,
|
||||
"total_cost": total_cost,
|
||||
"total_gain": total_gain,
|
||||
"path": path_spec,
|
||||
"scheme": scheme,
|
||||
"is_eligible": _is_eligible_funding_package(scheme, p.data["current-energy-efficiency"], sub_gain)
|
||||
})
|
||||
|
||||
solutions = pd.DataFrame(solutions)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue