urbanopt-reopt 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/release.yml +25 -0
- data/.github/workflows/nightly_ci_build.yml +9 -3
- data/CHANGELOG.md +10 -0
- data/LICENSE.md +1 -1
- data/RDOC_MAIN.md +13 -13
- data/README.md +14 -14
- data/doc_templates/LICENSE.md +1 -1
- data/doc_templates/copyright_erb.txt +1 -1
- data/docs/README.md +12 -12
- data/docs/package-lock.json +4806 -4836
- data/index.md +13 -13
- data/lib/urbanopt/reopt/feature_report_adapter.rb +12 -12
- data/lib/urbanopt/reopt/reopt_lite_api.rb +22 -22
- data/lib/urbanopt/reopt/reopt_post_processor.rb +23 -23
- data/lib/urbanopt/reopt/reopt_schema/reopt_input_schema.json +1 -1
- data/lib/urbanopt/reopt/reopt_schema/reopt_output_schema.json +1 -1
- data/lib/urbanopt/reopt/scenario/reopt_scenario_csv.rb +7 -7
- data/lib/urbanopt/reopt/scenario_report_adapter.rb +15 -15
- data/lib/urbanopt/reopt/version.rb +1 -1
- data/urbanopt-reopt.gemspec +5 -3
- metadata +35 -8
- data/Jenkinsfile +0 -10
data/index.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# **URBANopt REopt Gem**
|
2
2
|
|
3
|
-
The **URBANopt<sup>™</sup> REopt Gem** extends **URBANopt::Reporting::DefaultReports::ScenarioReport** and **URBANopt::Reporting::DefaultReports::FeatureReport** with the ability to derive cost-optimal distributed energy resource (DER) technology sizes and annual dispatch strageties via the [REopt
|
4
|
-
REopt
|
3
|
+
The **URBANopt<sup>™</sup> REopt Gem** extends **URBANopt::Reporting::DefaultReports::ScenarioReport** and **URBANopt::Reporting::DefaultReports::FeatureReport** with the ability to derive cost-optimal distributed energy resource (DER) technology sizes and annual dispatch strageties via the [REopt](https://reopt.nrel.gov/tool) decision support platform.
|
4
|
+
REopt is a technoeconomic model which leverages mixed integer linear programming to identify the cost-optimal sizing of solar PV, Wind, Storage and/or diesel generation given an electric load profile, a utility rate tariff and other technoeconomic parameters. See [https://developer.nrel.gov/docs/energy-optimization/reopt/v2/](https://developer.nrel.gov/docs/energy-optimization/reopt/v2/) for more detailed information on input parameters and default assumptions.
|
5
5
|
|
6
6
|
See the [example project](https://github.com/urbanopt/urbanopt-example-reopt-project.git) for more infomation about usage of this gem.
|
7
7
|
|
@@ -31,7 +31,7 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
## Functionality
|
33
33
|
|
34
|
-
This gem is used to call the REopt
|
34
|
+
This gem is used to call the REopt API on a Scenario Report or Feature Report to update the object's Distributed Generation attributes (including system financial and sizing metrics) as shown in an example below:
|
35
35
|
|
36
36
|
```
|
37
37
|
"distributed_generation": {
|
@@ -83,9 +83,9 @@ Moreover, the following optimal dispatch fields are added to its timeseries CSV.
|
|
83
83
|
| ElectricityProduced:Wind:ToGrid | kWh |
|
84
84
|
```
|
85
85
|
|
86
|
-
The REopt
|
86
|
+
The REopt has default values for all non-required input parameters that are used unless the user specifies custom assumptions. See [https://developer.nrel.gov/docs/energy-optimization/reopt/v2/](https://developer.nrel.gov/docs/energy-optimization/reopt/v2/) for more detailed information on input parameters and default assumptions.
|
87
87
|
|
88
|
-
<b>Note:</b> Required attributes for a REopt run include latitude and longitude. If no utility rate is specified in your REopt
|
88
|
+
<b>Note:</b> Required attributes for a REopt run include latitude and longitude. If no utility rate is specified in your REopt assumption settings, then a constant default rate of $0.13 is assumed without demand charges. Also, by default, only solar PV and storage are considered in the analysis (i.e. Wind and Generators are excluded from consideration).
|
89
89
|
|
90
90
|
|
91
91
|
|
@@ -101,19 +101,19 @@ feature_reports_hash = {} # <insert a Feature Report hash here>
|
|
101
101
|
#Create a Feature Report
|
102
102
|
feature_report = URBANopt::Reporting::DefaultReports::FeatureReport.new(feature_reports_hash)
|
103
103
|
|
104
|
-
#Specify a file name where REopt
|
104
|
+
#Specify a file name where REopt results will be written in JSON format
|
105
105
|
reopt_output_file = File.join(feature_report.directory_name, 'feature_report_reopt_run1.json')
|
106
106
|
|
107
|
-
#Specify a file name where the new timeseries CSV will be written after REopt
|
107
|
+
#Specify a file name where the new timeseries CSV will be written after REopt has determined cost optimal dispatch
|
108
108
|
timeseries_output_file = File.join(feature_report.directory_name, 'feature_report_timeseries1.csv')
|
109
109
|
|
110
|
-
#Specify non-default REopt
|
110
|
+
#Specify non-default REopt assumptions, saved in JSON format, to be used in calling the API
|
111
111
|
reopt_assumptions_file = File.join(File.dirname(__FILE__), '../files/reopt_assumptions_basic.json')
|
112
112
|
|
113
|
-
#Create a REopt
|
113
|
+
#Create a REopt Post Processor to call the API, note you will need a Developer.nrel.gov API key in this step
|
114
114
|
reopt_post_processor = URBANopt::REopt::REoptPostProcessor.new(nil, nil, nil, DEVELOPER_NREL_KEY)
|
115
115
|
|
116
|
-
#Call REopt
|
116
|
+
#Call REopt with the post processor to update the feature's distributed generation attributes and timeseries CSV.
|
117
117
|
updated_feature_report = reopt_post_processor.run_feature_report(feature_report,reopt_assumptions_file,reopt_output_file,timeseries_output_file)
|
118
118
|
|
119
119
|
```
|
@@ -142,13 +142,13 @@ scenario_report = URBANopt::Reporting::DefaultReports::ScenarioReport.new({:dire
|
|
142
142
|
scenario_report.add_feature_report(feature_report)
|
143
143
|
end
|
144
144
|
|
145
|
-
#Specify non-default REopt
|
145
|
+
#Specify non-default REopt assumptions, saved in JSON format, to be used in calling the API
|
146
146
|
reopt_assumptions_file = File.join(File.dirname(__FILE__), '../files/reopt_assumptions_basic.json')
|
147
147
|
|
148
|
-
#Create a REopt
|
148
|
+
#Create a REopt Post Processor to call the API, note you will need a Developer.nrel.gov API key in this step
|
149
149
|
reopt_post_processor = URBANopt::REopt::REoptPostProcessor.new(scenario_report, reopt_assumptions_file, nil, DEVELOPER_NREL_KEY)
|
150
150
|
|
151
|
-
#Call REopt
|
151
|
+
#Call REopt with the post processor once on the sceanrio's aggregated load to update the scenario's distributed generation attributes and timeseries CSV.
|
152
152
|
updated_scenario_report = reopt_post_processor.run_scenario_report(scenario_report)
|
153
153
|
|
154
154
|
```
|
@@ -14,7 +14,7 @@ module URBANopt # :nodoc:
|
|
14
14
|
module REopt # :nodoc:
|
15
15
|
class FeatureReportAdapter
|
16
16
|
##
|
17
|
-
# FeatureReportAdapter can convert a URBANopt::Reporting::DefaultReports::FeatureReport into a \REopt
|
17
|
+
# FeatureReportAdapter can convert a URBANopt::Reporting::DefaultReports::FeatureReport into a \REopt posts or update a URBANopt::Reporting::DefaultReports::FeatureReport from a \REopt response.
|
18
18
|
##
|
19
19
|
# [*parameters:*]
|
20
20
|
##
|
@@ -24,14 +24,14 @@ module URBANopt # :nodoc:
|
|
24
24
|
end
|
25
25
|
|
26
26
|
##
|
27
|
-
# Convert a FeatureReport into a \REopt
|
27
|
+
# Convert a FeatureReport into a \REopt post
|
28
28
|
#
|
29
29
|
# [*parameters:*]
|
30
30
|
#
|
31
|
-
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to use in converting the optional +reopt_assumptions_hash+ to a \REopt
|
32
|
-
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt
|
31
|
+
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to use in converting the optional +reopt_assumptions_hash+ to a \REopt post. If a +reopt_assumptions_hash+ is not provided, a default post will be updated from this FeatureReport and submitted to the \REopt API.
|
32
|
+
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt API containing default values. Values will be overwritten from the FeatureReport where available (i.e. latitude, roof_squarefeet). Missing optional parameters will be filled in with default values by the API.
|
33
33
|
#
|
34
|
-
# [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt
|
34
|
+
# [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt API
|
35
35
|
##
|
36
36
|
def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil, groundmount_photovoltaic = nil)
|
37
37
|
name = feature_report.name.delete ' '
|
@@ -40,7 +40,7 @@ module URBANopt # :nodoc:
|
|
40
40
|
if !reopt_assumptions_hash.nil?
|
41
41
|
reopt_inputs = reopt_assumptions_hash
|
42
42
|
else
|
43
|
-
@@logger.info('Using default REopt
|
43
|
+
@@logger.info('Using default REopt assumptions')
|
44
44
|
end
|
45
45
|
|
46
46
|
# Check FeatureReport has required data
|
@@ -104,7 +104,7 @@ module URBANopt # :nodoc:
|
|
104
104
|
end
|
105
105
|
# Clip to one non-leap year's worth of data
|
106
106
|
energy_timeseries_kw = energy_timeseries_kw.map { |e| e || 0 }[0, (feature_report.timesteps_per_hour * 8760)]
|
107
|
-
# Convert from the OpenDSS resolution to the REopt
|
107
|
+
# Convert from the OpenDSS resolution to the REopt resolution, if necessary
|
108
108
|
rescue StandardError
|
109
109
|
@@logger.error("Could not parse the annual electric load from the timeseries csv - #{feature_report.timeseries_csv.path}")
|
110
110
|
raise "Could not parse the annual electric load from the timeseries csv - #{feature_report.timeseries_csv.path}"
|
@@ -136,18 +136,18 @@ module URBANopt # :nodoc:
|
|
136
136
|
end
|
137
137
|
|
138
138
|
##
|
139
|
-
# Update a FeatureReport from a \REopt
|
139
|
+
# Update a FeatureReport from a \REopt response
|
140
140
|
#
|
141
141
|
# [*parameters:*]
|
142
142
|
#
|
143
|
-
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to update from a \REopt
|
144
|
-
# * +reopt_output+ - _Hash_ - A reponse hash from the \REopt
|
145
|
-
# * +timeseries_csv_path+ - _String_ - Optional. The path to a file at which a new timeseries CSV will be written. If not provided a file is created based on the run_uuid of the \REopt
|
143
|
+
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to update from a \REopt reponse hash.
|
144
|
+
# * +reopt_output+ - _Hash_ - A reponse hash from the \REopt API to use in overwriting FeatureReport technology sizes, costs and dispatch strategies.
|
145
|
+
# * +timeseries_csv_path+ - _String_ - Optional. The path to a file at which a new timeseries CSV will be written. If not provided a file is created based on the run_uuid of the \REopt optimization task.
|
146
146
|
#
|
147
147
|
# [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport.
|
148
148
|
##
|
149
149
|
def update_feature_report(feature_report, reopt_output, timeseries_csv_path = nil, resilience_stats = nil)
|
150
|
-
# Check if the \REopt
|
150
|
+
# Check if the \REopt response is valid
|
151
151
|
if reopt_output['outputs']['Scenario']['status'] != 'optimal'
|
152
152
|
@@logger.info("Warning cannot Feature Report #{feature_report.name} #{feature_report.id} - REopt optimization was non-optimal")
|
153
153
|
return feature_report
|
@@ -16,15 +16,15 @@ module URBANopt # :nodoc:
|
|
16
16
|
module REopt # :nodoc:
|
17
17
|
class REoptLiteAPI
|
18
18
|
##
|
19
|
-
# \REoptLiteAPI manages submitting optimization tasks to the \REopt
|
20
|
-
# Results can either be sourced from the production \REopt
|
19
|
+
# \REoptLiteAPI manages submitting optimization tasks to the \REopt API and recieving results.
|
20
|
+
# Results can either be sourced from the production \REopt API with an API key from developer.nrel.gov, or from
|
21
21
|
# a version running at localhost.
|
22
22
|
##
|
23
23
|
#
|
24
24
|
# [*parameters:*]
|
25
25
|
#
|
26
|
-
# * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt
|
27
|
-
# * +nrel_developer_key+ - _String_ - API key used to access the \REopt
|
26
|
+
# * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt API running on localhost. Default is false, such that the production version of \REopt is accessed.
|
27
|
+
# * +nrel_developer_key+ - _String_ - API key used to access the \REopt APi. Required only if localhost is false. Obtain from https://developer.nrel.gov/signup/
|
28
28
|
##
|
29
29
|
def initialize(nrel_developer_key = nil, use_localhost = false)
|
30
30
|
@use_localhost = use_localhost
|
@@ -53,9 +53,9 @@ module URBANopt # :nodoc:
|
|
53
53
|
#
|
54
54
|
# [*parameters:*]
|
55
55
|
#
|
56
|
-
# * +run_uuid+ - _String_ - Unique run_uuid obtained from the \REopt
|
56
|
+
# * +run_uuid+ - _String_ - Unique run_uuid obtained from the \REopt job submittal URL for a specific optimization task.
|
57
57
|
#
|
58
|
-
# [*return:*] _URI_ - Returns URI object for use in calling the \REopt
|
58
|
+
# [*return:*] _URI_ - Returns URI object for use in calling the \REopt results endpoint for a specifc optimization task.
|
59
59
|
##
|
60
60
|
def uri_results(run_uuid) # :nodoc:
|
61
61
|
if @use_localhost
|
@@ -71,9 +71,9 @@ module URBANopt # :nodoc:
|
|
71
71
|
#
|
72
72
|
# [*parameters:*]
|
73
73
|
#
|
74
|
-
# * +run_uuid+ - _String_ - Resilience statistics for a unique run_uuid obtained from the \REopt
|
74
|
+
# * +run_uuid+ - _String_ - Resilience statistics for a unique run_uuid obtained from the \REopt job submittal URL for a specific optimization task.
|
75
75
|
#
|
76
|
-
# [*return:*] _URI_ - Returns URI object for use in calling the \REopt
|
76
|
+
# [*return:*] _URI_ - Returns URI object for use in calling the \REopt resilience statistics endpoint for a specifc optimization task.
|
77
77
|
##
|
78
78
|
def uri_resilience(run_uuid) # :nodoc:
|
79
79
|
if @use_localhost
|
@@ -91,7 +91,7 @@ module URBANopt # :nodoc:
|
|
91
91
|
result = http.request(req)
|
92
92
|
# Result codes sourced from https://developer.nrel.gov/docs/errors/
|
93
93
|
if result.code == '429'
|
94
|
-
@@logger.fatal('Exceeded the REopt
|
94
|
+
@@logger.fatal('Exceeded the REopt API limit of 300 requests per hour')
|
95
95
|
puts 'Using the URBANopt CLI to submit a Scenario optimization counts as one request per scenario'
|
96
96
|
puts 'Using the URBANopt CLI to submit a Feature optimization counts as one request per feature'
|
97
97
|
abort('Please wait and try again once the time period has elapsed. The URBANopt CLI flag --reopt-keep-existing can be used to resume the optimization')
|
@@ -101,7 +101,7 @@ module URBANopt # :nodoc:
|
|
101
101
|
tries += 1
|
102
102
|
next
|
103
103
|
elsif (result.code != '201') && (result.code != '200') # Anything in the 200s is success
|
104
|
-
@@logger.warn("REopt
|
104
|
+
@@logger.warn("REopt has returned a '#{result.code}' status code. Visit https://developer.nrel.gov/docs/errors/ for more status code information")
|
105
105
|
# display error messages
|
106
106
|
json_res = JSON.parse(result.body, allow_nan: true)
|
107
107
|
json_res['messages'].delete('warnings') if json_res['messages']['warnings']
|
@@ -112,7 +112,7 @@ module URBANopt # :nodoc:
|
|
112
112
|
end
|
113
113
|
tries = max_tries
|
114
114
|
rescue StandardError => e
|
115
|
-
@@logger.debug("error from REopt
|
115
|
+
@@logger.debug("error from REopt API: #{e}")
|
116
116
|
if tries + 1 < max_tries
|
117
117
|
@@logger.debug('trying again...')
|
118
118
|
else
|
@@ -126,12 +126,12 @@ module URBANopt # :nodoc:
|
|
126
126
|
end
|
127
127
|
|
128
128
|
##
|
129
|
-
# Checks if a optimization task can be submitted to the \REopt
|
129
|
+
# Checks if a optimization task can be submitted to the \REopt API
|
130
130
|
##
|
131
131
|
#
|
132
132
|
# [*parameters:*]
|
133
133
|
#
|
134
|
-
# * +data+ - _Hash_ - Default \REopt
|
134
|
+
# * +data+ - _Hash_ - Default \REopt formatted post containing at least all the required parameters.
|
135
135
|
#
|
136
136
|
# [*return:*] _Bool_ - Returns true if the post succeeeds. Otherwise returns false.
|
137
137
|
##
|
@@ -156,15 +156,15 @@ module URBANopt # :nodoc:
|
|
156
156
|
end
|
157
157
|
|
158
158
|
##
|
159
|
-
# Completes a \REopt
|
159
|
+
# Completes a \REopt optimization. From a formatted hash, an optimization task is submitted to the API.
|
160
160
|
# Results are polled at 5 second interval until they are ready or an error is returned from the API. Results
|
161
161
|
# are written to disk.
|
162
162
|
##
|
163
163
|
#
|
164
164
|
# [*parameters:*]
|
165
165
|
#
|
166
|
-
# * +reopt_input+ - _Hash_ - \REopt
|
167
|
-
# * +filename+ - _String_ - Path to file that will be created containing the full \REopt
|
166
|
+
# * +reopt_input+ - _Hash_ - \REopt formatted post containing at least required parameters.
|
167
|
+
# * +filename+ - _String_ - Path to file that will be created containing the full \REopt response.
|
168
168
|
#
|
169
169
|
# [*return:*] _Bool_ - Returns true if the post succeeeds. Otherwise returns false.
|
170
170
|
##
|
@@ -211,7 +211,7 @@ module URBANopt # :nodoc:
|
|
211
211
|
# If database still hasn't updated, wait a little longer and try again
|
212
212
|
while (elapsed_time < max_elapsed_time) && (response && response.code == '404')
|
213
213
|
response = make_request(http, get_request)
|
214
|
-
@@logger.warn('GET request was too fast for REOpt-
|
214
|
+
@@logger.warn('GET request was too fast for REOpt-API. Retrying...')
|
215
215
|
elapsed_time += 5
|
216
216
|
sleep 5
|
217
217
|
end
|
@@ -236,22 +236,22 @@ module URBANopt # :nodoc:
|
|
236
236
|
end
|
237
237
|
|
238
238
|
##
|
239
|
-
# Completes a \REopt
|
239
|
+
# Completes a \REopt optimization. From a formatted hash, an optimization task is submitted to the API.
|
240
240
|
# Results are polled at 5 second interval until they are ready or an error is returned from the API. Results
|
241
241
|
# are written to disk.
|
242
242
|
##
|
243
243
|
#
|
244
244
|
# [*parameters:*]
|
245
245
|
#
|
246
|
-
# * +reopt_input+ - _Hash_ - \REopt
|
247
|
-
# * +filename+ - _String_ - Path to file that will be created containing the full \REopt
|
246
|
+
# * +reopt_input+ - _Hash_ - \REopt formatted post containing at least required parameters.
|
247
|
+
# * +filename+ - _String_ - Path to file that will be created containing the full \REopt response.
|
248
248
|
#
|
249
249
|
# [*return:*] _Bool_ - Returns true if the post succeeeds. Otherwise returns false.
|
250
250
|
##
|
251
251
|
def reopt_request(reopt_input, filename)
|
252
252
|
description = reopt_input[:Scenario][:description]
|
253
253
|
|
254
|
-
@@logger.info("Submitting #{description} to REopt
|
254
|
+
@@logger.info("Submitting #{description} to REopt API")
|
255
255
|
|
256
256
|
# Format the request
|
257
257
|
header = { 'Content-Type' => 'application/json' }
|
@@ -266,7 +266,7 @@ module URBANopt # :nodoc:
|
|
266
266
|
response = make_request(http, post_request)
|
267
267
|
if !response.is_a?(Net::HTTPSuccess)
|
268
268
|
@@logger.error('make_request Failed')
|
269
|
-
raise '
|
269
|
+
raise 'REopt connection Failed'
|
270
270
|
end
|
271
271
|
|
272
272
|
# Get UUID
|
@@ -12,16 +12,16 @@ module URBANopt # :nodoc:
|
|
12
12
|
module REopt # :nodoc:
|
13
13
|
class REoptPostProcessor
|
14
14
|
##
|
15
|
-
# \REoptPostProcessor updates a ScenarioReport or FeatureReport based on \REopt
|
15
|
+
# \REoptPostProcessor updates a ScenarioReport or FeatureReport based on \REopt optimization response.
|
16
16
|
##
|
17
17
|
#
|
18
18
|
# [*parameters:*]
|
19
19
|
#
|
20
|
-
# * +scenario_report+ - _ScenarioReport_ - Optional. A scenario report that has been returned from the URBANopt::Reporting::ScenarioDefaultPostProcessor - used in creating default output file names in \REopt
|
21
|
-
# * +scenario_reopt_assumptions_file+ - _String_ - Optional. JSON file formatted for a \REopt
|
22
|
-
# * +reopt_feature_assumptions+ - _Array_ - Optional. A list of JSON file formatted for a \REopt
|
23
|
-
# * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt
|
24
|
-
# * +nrel_developer_key+ - _String_ - API used to access the \REopt
|
20
|
+
# * +scenario_report+ - _ScenarioReport_ - Optional. A scenario report that has been returned from the URBANopt::Reporting::ScenarioDefaultPostProcessor - used in creating default output file names in \REopt optimizations.
|
21
|
+
# * +scenario_reopt_assumptions_file+ - _String_ - Optional. JSON file formatted for a \REopt analysis containing custom input parameters for optimizations at the Scenario Report level
|
22
|
+
# * +reopt_feature_assumptions+ - _Array_ - Optional. A list of JSON file formatted for a \REopt analysis containing custom input parameters for optimizations at the Feature Report level. The order and number of files must match the Feature Reports in the scenario_report input.
|
23
|
+
# * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt API running on localhost. Default is false, such that the production version of \REopt is accessed.
|
24
|
+
# * +nrel_developer_key+ - _String_ - API used to access the \REopt APi. Required only if +localhost+ is false. Obtain from https://developer.nrel.gov/signup/
|
25
25
|
##
|
26
26
|
def initialize(scenario_report, scenario_reopt_assumptions_file = nil, reopt_feature_assumptions = [], nrel_developer_key = nil, localhost = false)
|
27
27
|
# initialize @@logger
|
@@ -80,14 +80,14 @@ module URBANopt # :nodoc:
|
|
80
80
|
attr_accessor :scenario_reopt_default_assumptions_hash, :scenario_reopt_default_output_file, :scenario_timeseries_default_output_file, :feature_reports_reopt_default_assumption_hashes, :feature_reports_reopt_default_output_files, :feature_reports_timeseries_default_output_files
|
81
81
|
|
82
82
|
##
|
83
|
-
# Updates a FeatureReport based on an optional set of \REopt
|
83
|
+
# Updates a FeatureReport based on an optional set of \REopt optimization assumptions.
|
84
84
|
##
|
85
85
|
#
|
86
86
|
# [*parameters:*]
|
87
87
|
#
|
88
|
-
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport which will be used in creating and then updated by a \REopt
|
89
|
-
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt
|
90
|
-
# * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt
|
88
|
+
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport which will be used in creating and then updated by a \REopt opimization response.
|
89
|
+
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt formatted hash containing default parameters (i.e. utility rate, escalation rate) which will be updated by the FeatureReport (i.e. location, roof availability)
|
90
|
+
# * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt responses will be saved.
|
91
91
|
# * +timeseries_csv_path+ - _String_ - Optional. Path to a file at which the new timeseries CSV for the FeatureReport will be saved.
|
92
92
|
#
|
93
93
|
# [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport
|
@@ -120,14 +120,14 @@ module URBANopt # :nodoc:
|
|
120
120
|
end
|
121
121
|
|
122
122
|
##
|
123
|
-
# Updates a ScenarioReport based on an optional set of \REopt
|
123
|
+
# Updates a ScenarioReport based on an optional set of \REopt optimization assumptions.
|
124
124
|
##
|
125
125
|
#
|
126
126
|
# [*parameters:*]
|
127
127
|
#
|
128
|
-
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport which will be used in creating and then updated by a \REopt
|
129
|
-
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt
|
130
|
-
# * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt
|
128
|
+
# * +feature_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport which will be used in creating and then updated by a \REopt opimization response.
|
129
|
+
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt formatted hash containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability)
|
130
|
+
# * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt responses will be saved.
|
131
131
|
# * +timeseries_csv_path+ - _String_ - Optional. Path to a file at which the new timeseries CSV for the ScenarioReport will be saved.
|
132
132
|
#
|
133
133
|
# [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ Returns an updated ScenarioReport
|
@@ -176,14 +176,14 @@ module URBANopt # :nodoc:
|
|
176
176
|
return result
|
177
177
|
end
|
178
178
|
|
179
|
-
# Updates a set of FeatureReports based on an optional set of \REopt
|
179
|
+
# Updates a set of FeatureReports based on an optional set of \REopt optimization assumptions.
|
180
180
|
##
|
181
181
|
#
|
182
182
|
# [*parameters:*]
|
183
183
|
#
|
184
|
-
# * +feature_reports+ - _Array_ - An array of _URBANopt::Reporting::DefaultReports::FeatureReport_ objetcs which will each be used to create (and are subsquently updated by) a \REopt
|
185
|
-
# * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt
|
186
|
-
# * +reopt_output_files+ - _Array_ - Optional. A array of paths to files at which REpopt
|
184
|
+
# * +feature_reports+ - _Array_ - An array of _URBANopt::Reporting::DefaultReports::FeatureReport_ objetcs which will each be used to create (and are subsquently updated by) a \REopt opimization response.
|
185
|
+
# * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt formatted hashes containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability). The number and order of the hashes should match the feature_reports array.
|
186
|
+
# * +reopt_output_files+ - _Array_ - Optional. A array of paths to files at which REpopt responses will be saved. The number and order of the paths should match the feature_reports array.
|
187
187
|
# * +timeseries_csv_path+ - _Array_ - Optional. A array of paths to files at which the new timeseries CSV for the FeatureReports will be saved. The number and order of the paths should match the feature_reports array.
|
188
188
|
#
|
189
189
|
# [*return:*] _Array_ Returns an array of updated _URBANopt::Scenario::DefaultReports::FeatureReport_ objects
|
@@ -257,7 +257,7 @@ module URBANopt # :nodoc:
|
|
257
257
|
#
|
258
258
|
# [*parameters:*]
|
259
259
|
#
|
260
|
-
# * +output_file+ - _Array_ - Optional. An array of paths to files at which REpopt
|
260
|
+
# * +output_file+ - _Array_ - Optional. An array of paths to files at which REpopt responses will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
|
261
261
|
# [*return:*] _Boolean_ - Returns true if file or nonempty directory exist
|
262
262
|
def output_exists(output_file)
|
263
263
|
res = false
|
@@ -270,14 +270,14 @@ module URBANopt # :nodoc:
|
|
270
270
|
return res
|
271
271
|
end
|
272
272
|
|
273
|
-
# Updates a ScenarioReport based on an optional set of \REopt
|
273
|
+
# Updates a ScenarioReport based on an optional set of \REopt optimization assumptions.
|
274
274
|
##
|
275
275
|
#
|
276
276
|
# [*parameters:*]
|
277
277
|
#
|
278
|
-
# * +scenario_report+ - _Array_ - A _URBANopt::Reporting::DefaultReports::ScenarioReport_ which will each be used to create (and is subsquently updated by) \REopt
|
279
|
-
# * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt
|
280
|
-
# * +reopt_output_files+ - _Array_ - Optional. An array of paths to files at which REpopt
|
278
|
+
# * +scenario_report+ - _Array_ - A _URBANopt::Reporting::DefaultReports::ScenarioReport_ which will each be used to create (and is subsquently updated by) \REopt opimization responses for each of its FeatureReports.
|
279
|
+
# * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt formatted hashes containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability). The number and order of the hashes should match the array in ScenarioReport.feature_reports.
|
280
|
+
# * +reopt_output_files+ - _Array_ - Optional. An array of paths to files at which REpopt responses will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
|
281
281
|
# * +feature_report_timeseries_csv_paths+ - _Array_ - Optional. An array of paths to files at which the new timeseries CSV for the FeatureReports will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
|
282
282
|
#
|
283
283
|
# [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ - Returns an updated ScenarioReport
|
@@ -16,9 +16,9 @@ module URBANopt
|
|
16
16
|
class REoptScenarioCSV < ScenarioCSV
|
17
17
|
##
|
18
18
|
# REoptScenarioCSV is an extension of ScenarioCSV which assigns a Simulation Mapper to each Feature in a FeatureFile using a simple CSV format.
|
19
|
-
# The a \REopt
|
20
|
-
# A REoptScenarioCSV can be instantiated with set of assumptions to use in \REopt
|
21
|
-
# A REoptScenarioCSV is also instantiated with a +reopt_files_dir+ file directory containing all \REopt
|
19
|
+
# The a \REopt enabled CSV file has four columns 1) feature_id, 2) feature_name, 3) mapper_class_name and 4) optional reopt assumptions file name. There is one row for each Feature.
|
20
|
+
# A REoptScenarioCSV can be instantiated with set of assumptions to use in \REopt for an optimization at the aggregated ScenarioReport level.
|
21
|
+
# A REoptScenarioCSV is also instantiated with a +reopt_files_dir+ file directory containing all \REopt assumptions files (required only if the ScenarioReport or its FeatureReports will have specified assumptions).
|
22
22
|
#
|
23
23
|
# [*parameters:*]
|
24
24
|
#
|
@@ -29,8 +29,8 @@ module URBANopt
|
|
29
29
|
# * +mapper_files_dir+ - _String_ - Directory containing all mapper class files containing MapperBase definitions.
|
30
30
|
# * +csv_file+ - _String_ - Path to CSV file assigning a MapperBase class to each feature in feature_file.
|
31
31
|
# * +num_header_rows+ - _String_ - Number of header rows to skip in CSV file.
|
32
|
-
# * +reopt_files_dir+ - _String_ - Path to folder containing default \REopt
|
33
|
-
# * +scenario_reopt_assumptions_file_name+ - _String_ - Name of .json file in the +reopt_files_dir+ location to use in assessing the aggregated ScenarioReport in \REopt
|
32
|
+
# * +reopt_files_dir+ - _String_ - Path to folder containing default \REopt assumptions JSON's.
|
33
|
+
# * +scenario_reopt_assumptions_file_name+ - _String_ - Name of .json file in the +reopt_files_dir+ location to use in assessing the aggregated ScenarioReport in \REopt.
|
34
34
|
##
|
35
35
|
def initialize(name, root_dir, run_dir, feature_file, mapper_files_dir, csv_file, num_header_rows, reopt_files_dir = nil, scenario_reopt_assumptions_file_name = nil)
|
36
36
|
super(name, root_dir, run_dir, feature_file, mapper_files_dir, csv_file, num_header_rows)
|
@@ -66,12 +66,12 @@ module URBANopt
|
|
66
66
|
feature_id = row[0].chomp
|
67
67
|
feature_name = row[1].chomp
|
68
68
|
mapper_class = row[2].chomp
|
69
|
-
# Assume fourth columns, if exists, contains the name of the JSON file in the reopt_files_dir to use when running \REopt
|
69
|
+
# Assume fourth columns, if exists, contains the name of the JSON file in the reopt_files_dir to use when running \REopt for the feature report
|
70
70
|
|
71
71
|
if row.length > 3 && !@reopt_files_dir.nil?
|
72
72
|
@reopt_feature_assumptions[idx - 1] = File.join(@reopt_files_dir, row[3].chomp)
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
# gets +features+ from the feature_file.
|
76
76
|
features = []
|
77
77
|
feature = feature_file.get_feature_by_id(feature_id)
|
@@ -14,7 +14,7 @@ module URBANopt # :nodoc:
|
|
14
14
|
module REopt # :nodoc:
|
15
15
|
class ScenarioReportAdapter
|
16
16
|
##
|
17
|
-
# ScenarioReportAdapter can convert a ScenarioReport into a \REopt
|
17
|
+
# ScenarioReportAdapter can convert a ScenarioReport into a \REopt posts or updates a ScenarioReport and its FeatureReports from \REopt response(s)
|
18
18
|
##
|
19
19
|
# [*parameters:*]
|
20
20
|
def initialize
|
@@ -23,26 +23,26 @@ module URBANopt # :nodoc:
|
|
23
23
|
end
|
24
24
|
|
25
25
|
##
|
26
|
-
# Convert a ScenarioReport into a \REopt
|
26
|
+
# Convert a ScenarioReport into a \REopt post
|
27
27
|
#
|
28
28
|
# [*parameters:*]
|
29
29
|
#
|
30
|
-
# * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting the +reopt_assumptions_hash+, if provided, to a \REopt
|
31
|
-
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt
|
30
|
+
# * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting the +reopt_assumptions_hash+, if provided, to a \REopt post. Otherwise, if the +reopt_assumptions_hash+ is nil a default post will be updated from this ScenarioReport and submitted to the \REopt API.
|
31
|
+
# * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt API containing default values. Values will be overwritten from the ScenarioReport where available (i.e. latitude, roof_squarefeet). Missing optional parameters will be filled in with default values by the API.
|
32
32
|
#
|
33
|
-
# [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt
|
33
|
+
# [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt API
|
34
34
|
##
|
35
35
|
def reopt_json_from_scenario_report(scenario_report, reopt_assumptions_json = nil, community_photovoltaic = nil)
|
36
36
|
name = scenario_report.name.delete ' '
|
37
37
|
scenario_id = scenario_report.id.delete ' '
|
38
38
|
description = "scenario_report_#{name}_#{scenario_id}"
|
39
39
|
|
40
|
-
# Create base REpopt
|
40
|
+
# Create base REpopt post
|
41
41
|
reopt_inputs = { Scenario: { Site: { ElectricTariff: { blended_monthly_demand_charges_us_dollars_per_kw: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], blended_monthly_rates_us_dollars_per_kwh: [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13] }, LoadProfile: {}, Wind: { max_kw: 0 } } } }
|
42
42
|
if !reopt_assumptions_json.nil?
|
43
43
|
reopt_inputs = reopt_assumptions_json
|
44
44
|
else
|
45
|
-
@@logger.info('Using default REopt
|
45
|
+
@@logger.info('Using default REopt assumptions')
|
46
46
|
end
|
47
47
|
|
48
48
|
# Update required info
|
@@ -144,14 +144,14 @@ module URBANopt # :nodoc:
|
|
144
144
|
end
|
145
145
|
|
146
146
|
##
|
147
|
-
# Converts a FeatureReport list from a ScenarioReport into an array of \REopt
|
147
|
+
# Converts a FeatureReport list from a ScenarioReport into an array of \REopt posts
|
148
148
|
#
|
149
149
|
# [*parameters:*]
|
150
150
|
#
|
151
|
-
# * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting FeatureReports and respecitive +reopt_assumptions_hashes+, if provided, to a \REopt
|
152
|
-
# * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of hashes formatted for submittal to the \REopt
|
151
|
+
# * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to use in converting FeatureReports and respecitive +reopt_assumptions_hashes+, if provided, to a \REopt post. If no +reopt_assumptions_hashes+ are provided default posts will be updated from these FeatureReports and submitted to the \REopt API.
|
152
|
+
# * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of hashes formatted for submittal to the \REopt API containing default values. Values will be overwritten from the ScenarioReport where available (i.e. latitude, roof_squarefeet). Missing optional parameters will be filled in with default values by the API. The order should match the list in ScenarioReport.feature_reports.
|
153
153
|
#
|
154
|
-
# [*return:*] _Array_ - Returns an array of hashes formatted for submittal to the \REopt
|
154
|
+
# [*return:*] _Array_ - Returns an array of hashes formatted for submittal to the \REopt API in the order of the FeatureReports lited in ScenarioReport.feature_reports.
|
155
155
|
##
|
156
156
|
def reopt_jsons_from_scenario_feature_reports(scenario_report, reopt_assumptions_hashes = [])
|
157
157
|
results = []
|
@@ -189,13 +189,13 @@ module URBANopt # :nodoc:
|
|
189
189
|
end
|
190
190
|
|
191
191
|
##
|
192
|
-
# Updates a ScenarioReport from a \REopt
|
192
|
+
# Updates a ScenarioReport from a \REopt response
|
193
193
|
#
|
194
194
|
# [*parameters:*]
|
195
195
|
#
|
196
|
-
# * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to update from a \REopt
|
197
|
-
# * +reopt_output+ - _Hash_ - A hash response from the \REopt
|
198
|
-
# * +timeseries_csv_path+ - _String_ - Optional. The path to a file at which new timeseries data will be written. If not provided a file is created based on the run_uuid of the \REopt
|
196
|
+
# * +scenario_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport to update from a \REopt response.
|
197
|
+
# * +reopt_output+ - _Hash_ - A hash response from the \REopt API.
|
198
|
+
# * +timeseries_csv_path+ - _String_ - Optional. The path to a file at which new timeseries data will be written. If not provided a file is created based on the run_uuid of the \REopt optimization task.
|
199
199
|
#
|
200
200
|
# [*return:*] _URBANopt::Reporting::DefaultReports::ScenarioReport_ - Returns an updated ScenarioReport
|
201
201
|
##
|
data/urbanopt-reopt.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ['']
|
10
10
|
spec.licenses = 'Nonstandard'
|
11
11
|
|
12
|
-
spec.summary = 'Accessing the REopt
|
13
|
-
spec.description = 'Classes and measures for utilizing the REopt
|
12
|
+
spec.summary = 'Accessing the REopt API within OpenStudio workflows.'
|
13
|
+
spec.description = 'Classes and measures for utilizing the REopt API within OpenStudio workflows.'
|
14
14
|
spec.homepage = 'https://github.com/urbanopt/urbanopt-reopt-gem'
|
15
15
|
|
16
16
|
# Specify which files should be added to the gem when it is released.
|
@@ -27,9 +27,11 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
28
28
|
spec.add_development_dependency 'rake', '~> 13.0'
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 1.15.0'
|
30
31
|
spec.add_development_dependency 'simplecov', '~> 0.18.2'
|
31
32
|
spec.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
|
33
|
+
spec.add_development_dependency 'openstudio-extension', '~> 0.7.1'
|
32
34
|
|
33
35
|
spec.add_dependency 'certified', '~> 1'
|
34
|
-
spec.add_dependency 'urbanopt-scenario', '~> 0.
|
36
|
+
spec.add_dependency 'urbanopt-scenario', '~> 0.11.0'
|
35
37
|
end
|