Skip to content

Commit

Permalink
Add upgrade name field to ApplyUpgrade measure and results csv. Reduc…
Browse files Browse the repository at this point in the history
…e number of cost value/multiplier pairs from 5 to 2 per option.
  • Loading branch information
shorowit committed Aug 24, 2017
1 parent eaf521e commit f84ba2b
Show file tree
Hide file tree
Showing 23 changed files with 4,510 additions and 24,048 deletions.
14 changes: 13 additions & 1 deletion measures/ApplyUpgrade/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ def num_options
end

def num_costs_per_option
return 5 # Sync with SimulationOutputReport measure
return 2 # Sync with SimulationOutputReport measure
end

# define the arguments that the user will input
def arguments(model)
args = OpenStudio::Ruleset::OSArgumentVector.new

# Make string arg for upgrade name
upgrade_name = OpenStudio::Ruleset::OSArgument::makeStringArgument("upgrade_name",true)
upgrade_name.setDisplayName("Upgrade Name")
upgrade_name.setDescription("User-specificed name that describes the upgrade.")
upgrade_name.setDefaultValue("My Upgrade")
args << upgrade_name

# Make integer arg to run measure [1 is run, 0 is no run]
run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument("run_measure",true)
run_measure.setDisplayName("Run Measure")
Expand Down Expand Up @@ -119,6 +126,8 @@ def run(model, runner, user_arguments)
runner.registerAsNotApplicable("Run Measure set to #{run_measure}.")
return true
end

upgrade_name = runner.getStringArgumentValue("upgrade_name",user_arguments)

# Retrieve Option X argument values
options = {}
Expand Down Expand Up @@ -282,6 +291,9 @@ def run(model, runner, user_arguments)

end # apply_package_upgrade

# Register the upgrade name
register_value(runner, "upgrade_name", upgrade_name)

if measures.size == 0
# Upgrade not applied; don't re-run existing home simulation
runner.haltWorkflow('Invalid')
Expand Down
2,837 changes: 223 additions & 2,614 deletions measures/ApplyUpgrade/measure.xml

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion measures/SimulationOutputReport/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def outputs
"hours_cooling_setpoint_not_met",
"hvac_cooling_capacity_w",
"hvac_heating_capacity_w",
"upgrade_name",
"upgrade_cost_usd",
"weight"
]
Expand Down Expand Up @@ -199,14 +200,22 @@ def run(runner, user_arguments)
runner.registerInfo("Registering #{weight} for weight.")
end

# UPGRADE NAME
upgrade_name = get_value_from_runner_past_results(runner, "upgrade_name", "apply_upgrade", false)
if upgrade_name.nil?
upgrade_name = ""
end
runner.registerValue("upgrade_name", upgrade_name)
runner.registerInfo("Registering #{upgrade_name} for upgrade_name.")

# UPGRADE COSTS

upgrade_cost_name = "upgrade_cost_usd"

# Get upgrade cost value/multiplier pairs from the upgrade measure
cost_pairs = []
for option_num in 1..10 # Sync with ApplyUpgrade measure
for cost_num in 1..5 # Sync with ApplyUpgrade measure
for cost_num in 1..2 # Sync with ApplyUpgrade measure
cost_value = get_value_from_runner_past_results(runner, "option_#{option_num}_cost_#{cost_num}_value_to_apply", "apply_upgrade", false)
next if cost_value.nil?
cost_mult_type = get_value_from_runner_past_results(runner, "option_#{option_num}_cost_#{cost_num}_multiplier_to_apply", "apply_upgrade", false)
Expand Down
13 changes: 10 additions & 3 deletions measures/SimulationOutputReport/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>simulation_output_report</name>
<uid>fc337100-8634-404e-8966-01243d292a79</uid>
<version_id>b374e233-42ce-4c5f-9571-b68a1401fdc7</version_id>
<version_modified>20170630T224753Z</version_modified>
<version_id>7d3c8688-2379-4809-b7bd-13f48d6f51e6</version_id>
<version_modified>20170824T182419Z</version_modified>
<xml_checksum>2C8A3EEF</xml_checksum>
<class_name>SimulationOutputReport</class_name>
<display_name>Simulation Output Report</display_name>
Expand Down Expand Up @@ -186,6 +186,13 @@
<type>Double</type>
<model_dependent>false</model_dependent>
</output>
<output>
<name>upgrade_name</name>
<display_name>upgrade_name</display_name>
<short_name>upgrade_name</short_name>
<type>Double</type>
<model_dependent>false</model_dependent>
</output>
<output>
<name>upgrade_cost_usd</name>
<display_name>upgrade_cost_usd</display_name>
Expand Down Expand Up @@ -227,7 +234,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>824193A9</checksum>
<checksum>0898FAEC</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def outputs
"hours_cooling_setpoint_not_met",
"hvac_cooling_capacity_w",
"hvac_heating_capacity_w",
"upgrade_name",
"upgrade_cost_usd",
"weight"
]
Expand Down Expand Up @@ -199,14 +200,22 @@ def run(runner, user_arguments)
runner.registerInfo("Registering #{weight} for weight.")
end

# UPGRADE NAME
upgrade_name = get_value_from_runner_past_results(runner, "upgrade_name", "apply_upgrade", false)
if upgrade_name.nil?
upgrade_name = ""
end
runner.registerValue("upgrade_name", upgrade_name)
runner.registerInfo("Registering #{upgrade_name} for upgrade_name.")

# UPGRADE COSTS

upgrade_cost_name = "upgrade_cost_usd"

# Get upgrade cost value/multiplier pairs from the upgrade measure
cost_pairs = []
for option_num in 1..10 # Sync with ApplyUpgrade measure
for cost_num in 1..5 # Sync with ApplyUpgrade measure
for cost_num in 1..2 # Sync with ApplyUpgrade measure
cost_value = get_value_from_runner_past_results(runner, "option_#{option_num}_cost_#{cost_num}_value_to_apply", "apply_upgrade", false)
next if cost_value.nil?
cost_mult_type = get_value_from_runner_past_results(runner, "option_#{option_num}_cost_#{cost_num}_multiplier_to_apply", "apply_upgrade", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>simulation_output_report</name>
<uid>fc337100-8634-404e-8966-01243d292a79</uid>
<version_id>b374e233-42ce-4c5f-9571-b68a1401fdc7</version_id>
<version_modified>20170630T224753Z</version_modified>
<version_id>7d3c8688-2379-4809-b7bd-13f48d6f51e6</version_id>
<version_modified>20170824T182419Z</version_modified>
<xml_checksum>2C8A3EEF</xml_checksum>
<class_name>SimulationOutputReport</class_name>
<display_name>Simulation Output Report</display_name>
Expand Down Expand Up @@ -186,6 +186,13 @@
<type>Double</type>
<model_dependent>false</model_dependent>
</output>
<output>
<name>upgrade_name</name>
<display_name>upgrade_name</display_name>
<short_name>upgrade_name</short_name>
<type>Double</type>
<model_dependent>false</model_dependent>
</output>
<output>
<name>upgrade_cost_usd</name>
<display_name>upgrade_cost_usd</display_name>
Expand Down Expand Up @@ -227,7 +234,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>824193A9</checksum>
<checksum>0898FAEC</checksum>
</file>
</files>
</measure>

3 comments on commit f84ba2b

@shorowit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joseph-robertson there is now an upgrade_name column in the results.csv, so you can remove it from your post-processing script.

@joseph-robertson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will do that when we have an updated results csv.

@shorowit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.