diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index cf18e0cd..40d355a6 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -264,7 +264,7 @@ class SolarPvRecommendations: scaffolding_options=self.scaffolding_options, n_floors=self.property.number_of_floors ) - description = solar_pv_product['description'] + description = f"solar_pv_product['description'] - {solar_pv_product['size']} kWp system" if self.property.in_conservation_area: description += " Property is in a consevation area - please check with local planning authority." diff --git a/recommendations/optimiser/funding_optimiser.py b/recommendations/optimiser/funding_optimiser.py index f48ce024..d62b4f46 100644 --- a/recommendations/optimiser/funding_optimiser.py +++ b/recommendations/optimiser/funding_optimiser.py @@ -21,7 +21,7 @@ from backend.Funding import Funding logger = setup_logger() # measures we DO NOT treat as fundable in the ECO4 'funded' pass -_ECO4_EXCLUDE_TYPES = {"secondary_heating"} +_ECO4_EXCLUDE_TYPES = {"secondary_heating", "extension_cavity_wall_insulation", "sealing_open_fireplace"} def _path_scheme(path_spec): @@ -314,11 +314,17 @@ def optimise_with_funding_paths(p, input_measures, housing_type, funding: Fundin # 4) run your existing optimiser for the remaining groups # If we have a budget, we need to ensure the subproblem respects it so we remove the fixed cost (which # may already be over budget) and the fixed gain (which may not be achievable) - picked, sub_cost, sub_gain = run_optimizer( - sub_measures, - budget - fixed_cost if budget is not None else None, - sub_target_gain=target_gain - fixed_gain if target_gain is not None else None - ) + + if fixed_gain > target_gain: + picked, sub_cost, sub_gain = ([], 0.0, 0.0) + elif fixed_gain < target_gain and not sub_measures: + picked, sub_cost, sub_gain = ([], 0.0, 0.0) + else: + picked, sub_cost, sub_gain = run_optimizer( + sub_measures, + budget - fixed_cost if budget is not None else None, + sub_target_gain=target_gain - fixed_gain if target_gain is not None else None + ) if picked is None: continue @@ -346,14 +352,14 @@ def optimise_with_funding_paths(p, input_measures, housing_type, funding: Fundin # We find the indexes of the picked types picked_group_index = {} for pt in picked_types: - for gi, grp in enumerate(optimisation_input_measures): + for gi, grp in enumerate(input_measures): if any(pt in opt["type"] for opt in grp): picked_group_index[pt] = gi break # We get the remaining types # ECO4 case remaining = [] - for i, grp in enumerate(optimisation_input_measures): + for i, grp in enumerate(input_measures): if i in picked_group_index.values(): continue keep = [x for x in grp if x["type"] not in picked_types] @@ -677,8 +683,8 @@ def _make_solar_heating_funding_paths( # Solar PV with existing eligible heating system # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ has_eligible_heating_system = funding.check_solar_eligible_heating_system( - mainheat_description=p.main_heating["clean_description"], - heating_control_description=p.main_heating_controls["clean_description"] + mainheat_description=p.main_heating["clean_description"].lower(), + heating_control_description=p.main_heating_controls["clean_description"].lower() ) if has_eligible_heating_system and _find_measure(input_measures, "solar_pv"):