Skip to content

Commit

Permalink
Simplify upgrade step
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeee committed Jul 9, 2024
1 parent 976efd4 commit 9650b13
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions buildstockbatch/workflow_generator/residential/residential_hpxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,38 +171,36 @@ def create_osw(self, sim_id, building_id, upgrade_idx):
return osw

def add_upgrade_step_to_osw(self, upgrade_idx, osw):
num_regular_upgrades = len(self.cfg.get("upgrades", []))
if upgrade_idx is None:
return

if upgrade_idx < num_regular_upgrades:
measure_d = self.cfg["upgrades"][upgrade_idx]
apply_upgrade_measure = {
"measure_dir_name": "ApplyUpgrade",
"arguments": {"run_measure": 1},
}
if "upgrade_name" in measure_d:
apply_upgrade_measure["arguments"]["upgrade_name"] = measure_d["upgrade_name"]
for opt_num, option in enumerate(measure_d["options"], 1):
apply_upgrade_measure["arguments"]["option_{}".format(opt_num)] = option["option"]
if "lifetime" in option:
apply_upgrade_measure["arguments"]["option_{}_lifetime".format(opt_num)] = option["lifetime"]
if "apply_logic" in option:
apply_upgrade_measure["arguments"]["option_{}_apply_logic".format(opt_num)] = (
self.make_apply_logic_arg(option["apply_logic"])
)
for cost_num, cost in enumerate(option.get("costs", []), 1):
for arg in ("value", "multiplier"):
if arg not in cost:
continue
apply_upgrade_measure["arguments"]["option_{}_cost_{}_{}".format(opt_num, cost_num, arg)] = (
cost[arg]
)
if "package_apply_logic" in measure_d:
apply_upgrade_measure["arguments"]["package_apply_logic"] = self.make_apply_logic_arg(
measure_d["package_apply_logic"]
measure_d = self.cfg["upgrades"][upgrade_idx]
apply_upgrade_measure = {
"measure_dir_name": "ApplyUpgrade",
"arguments": {"run_measure": 1},
}
if "upgrade_name" in measure_d:
apply_upgrade_measure["arguments"]["upgrade_name"] = measure_d["upgrade_name"]
for opt_num, option in enumerate(measure_d["options"], 1):
apply_upgrade_measure["arguments"]["option_{}".format(opt_num)] = option["option"]
if "lifetime" in option:
apply_upgrade_measure["arguments"]["option_{}_lifetime".format(opt_num)] = option["lifetime"]
if "apply_logic" in option:
apply_upgrade_measure["arguments"]["option_{}_apply_logic".format(opt_num)] = self.make_apply_logic_arg(
option["apply_logic"]
)
osw["steps"].insert(1, apply_upgrade_measure) # right after BuildExistingModel
for cost_num, cost in enumerate(option.get("costs", []), 1):
for arg in ("value", "multiplier"):
if arg not in cost:
continue
apply_upgrade_measure["arguments"]["option_{}_cost_{}_{}".format(opt_num, cost_num, arg)] = cost[
arg
]
if "package_apply_logic" in measure_d:
apply_upgrade_measure["arguments"]["package_apply_logic"] = self.make_apply_logic_arg(
measure_d["package_apply_logic"]
)
osw["steps"].insert(1, apply_upgrade_measure) # right after BuildExistingModel

def _get_measure_args(self, workflow_block_args, measure_dir_name, debug):
"""
Expand Down

0 comments on commit 9650b13

Please sign in to comment.