urbanopt-reopt 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/index.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # **URBANopt REopt Gem**
2
2
 
3
- The **URBANopt<sup>&trade;</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 Lite](https://reopt.nrel.gov/tool) decision support platform.
4
- REopt Lite 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.
3
+ The **URBANopt<sup>&trade;</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 Lite 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:
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 Lite 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.
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 Lite 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).
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 Lite results will be written in JSON format
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 Lite has determined cost optimal dispatch
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 Lite assumptions, saved in JSON format, to be used in calling the API
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 Lite Post Processor to call the API, note you will need a Developer.nrel.gov API key in this step
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 Lite with the post processor to update the feature's distributed generation attributes and timeseries CSV.
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 Lite assumptions, saved in JSON format, to be used in calling the API
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 Lite Post Processor to call the API, note you will need a Developer.nrel.gov API key in this step
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 Lite with the post processor once on the sceanrio's aggregated load to update the scenario's distributed generation attributes and timeseries CSV.
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
  ```
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'openstudio/extension'
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'urbanopt/reporting/default_reports'
@@ -39,7 +14,7 @@ module URBANopt # :nodoc:
39
14
  module REopt # :nodoc:
40
15
  class FeatureReportAdapter
41
16
  ##
42
- # FeatureReportAdapter can convert a URBANopt::Reporting::DefaultReports::FeatureReport into a \REopt Lite posts or update a URBANopt::Reporting::DefaultReports::FeatureReport from a \REopt Lite response.
17
+ # FeatureReportAdapter can convert a URBANopt::Reporting::DefaultReports::FeatureReport into a \REopt posts or update a URBANopt::Reporting::DefaultReports::FeatureReport from a \REopt response.
43
18
  ##
44
19
  # [*parameters:*]
45
20
  ##
@@ -49,14 +24,14 @@ module URBANopt # :nodoc:
49
24
  end
50
25
 
51
26
  ##
52
- # Convert a FeatureReport into a \REopt Lite post
27
+ # Convert a FeatureReport into a \REopt post
53
28
  #
54
29
  # [*parameters:*]
55
30
  #
56
- # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to use in converting the optional +reopt_assumptions_hash+ to a \REopt Lite post. If a +reopt_assumptions_hash+ is not provided, a default post will be updated from this FeatureReport and submitted to the \REopt Lite API.
57
- # * +reopt_assumptions_hash+ - _Hash_ - Optional. A hash formatted for submittal to the \REopt Lite 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.
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.
58
33
  #
59
- # [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt Lite API
34
+ # [*return:*] _Hash_ - Returns hash formatted for submittal to the \REopt API
60
35
  ##
61
36
  def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil, groundmount_photovoltaic = nil)
62
37
  name = feature_report.name.delete ' '
@@ -65,7 +40,7 @@ module URBANopt # :nodoc:
65
40
  if !reopt_assumptions_hash.nil?
66
41
  reopt_inputs = reopt_assumptions_hash
67
42
  else
68
- @@logger.info('Using default REopt Lite assumptions')
43
+ @@logger.info('Using default REopt assumptions')
69
44
  end
70
45
 
71
46
  # Check FeatureReport has required data
@@ -129,7 +104,7 @@ module URBANopt # :nodoc:
129
104
  end
130
105
  # Clip to one non-leap year's worth of data
131
106
  energy_timeseries_kw = energy_timeseries_kw.map { |e| e || 0 }[0, (feature_report.timesteps_per_hour * 8760)]
132
- # Convert from the OpenDSS resolution to the REopt Lite resolution, if necessary
107
+ # Convert from the OpenDSS resolution to the REopt resolution, if necessary
133
108
  rescue StandardError
134
109
  @@logger.error("Could not parse the annual electric load from the timeseries csv - #{feature_report.timeseries_csv.path}")
135
110
  raise "Could not parse the annual electric load from the timeseries csv - #{feature_report.timeseries_csv.path}"
@@ -161,18 +136,18 @@ module URBANopt # :nodoc:
161
136
  end
162
137
 
163
138
  ##
164
- # Update a FeatureReport from a \REopt Lite response
139
+ # Update a FeatureReport from a \REopt response
165
140
  #
166
141
  # [*parameters:*]
167
142
  #
168
- # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport to update from a \REopt Lite reponse hash.
169
- # * +reopt_output+ - _Hash_ - A reponse hash from the \REopt Lite API to use in overwriting FeatureReport technology sizes, costs and dispatch strategies.
170
- # * +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 Lite optimization task.
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.
171
146
  #
172
147
  # [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport.
173
148
  ##
174
149
  def update_feature_report(feature_report, reopt_output, timeseries_csv_path = nil, resilience_stats = nil)
175
- # Check if the \REopt Lite response is valid
150
+ # Check if the \REopt response is valid
176
151
  if reopt_output['outputs']['Scenario']['status'] != 'optimal'
177
152
  @@logger.info("Warning cannot Feature Report #{feature_report.name} #{feature_report.id} - REopt optimization was non-optimal")
178
153
  return feature_report
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'net/https'
@@ -41,15 +16,15 @@ module URBANopt # :nodoc:
41
16
  module REopt # :nodoc:
42
17
  class REoptLiteAPI
43
18
  ##
44
- # \REoptLiteAPI manages submitting optimization tasks to the \REopt Lite API and recieving results.
45
- # Results can either be sourced from the production \REopt Lite API with an API key from developer.nrel.gov, or from
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
46
21
  # a version running at localhost.
47
22
  ##
48
23
  #
49
24
  # [*parameters:*]
50
25
  #
51
- # * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt Lite API running on localhost. Default is false, such that the production version of \REopt Lite is accessed.
52
- # * +nrel_developer_key+ - _String_ - API key used to access the \REopt Lite APi. Required only if localhost is false. Obtain from https://developer.nrel.gov/signup/
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/
53
28
  ##
54
29
  def initialize(nrel_developer_key = nil, use_localhost = false)
55
30
  @use_localhost = use_localhost
@@ -78,9 +53,9 @@ module URBANopt # :nodoc:
78
53
  #
79
54
  # [*parameters:*]
80
55
  #
81
- # * +run_uuid+ - _String_ - Unique run_uuid obtained from the \REopt Lite job submittal URL for a specific optimization task.
56
+ # * +run_uuid+ - _String_ - Unique run_uuid obtained from the \REopt job submittal URL for a specific optimization task.
82
57
  #
83
- # [*return:*] _URI_ - Returns URI object for use in calling the \REopt Lite results endpoint for a specifc optimization task.
58
+ # [*return:*] _URI_ - Returns URI object for use in calling the \REopt results endpoint for a specifc optimization task.
84
59
  ##
85
60
  def uri_results(run_uuid) # :nodoc:
86
61
  if @use_localhost
@@ -96,9 +71,9 @@ module URBANopt # :nodoc:
96
71
  #
97
72
  # [*parameters:*]
98
73
  #
99
- # * +run_uuid+ - _String_ - Resilience statistics for a unique run_uuid obtained from the \REopt Lite job submittal URL for a specific optimization task.
74
+ # * +run_uuid+ - _String_ - Resilience statistics for a unique run_uuid obtained from the \REopt job submittal URL for a specific optimization task.
100
75
  #
101
- # [*return:*] _URI_ - Returns URI object for use in calling the \REopt Lite resilience statistics endpoint for a specifc optimization task.
76
+ # [*return:*] _URI_ - Returns URI object for use in calling the \REopt resilience statistics endpoint for a specifc optimization task.
102
77
  ##
103
78
  def uri_resilience(run_uuid) # :nodoc:
104
79
  if @use_localhost
@@ -116,7 +91,7 @@ module URBANopt # :nodoc:
116
91
  result = http.request(req)
117
92
  # Result codes sourced from https://developer.nrel.gov/docs/errors/
118
93
  if result.code == '429'
119
- @@logger.fatal('Exceeded the REopt-Lite API limit of 300 requests per hour')
94
+ @@logger.fatal('Exceeded the REopt API limit of 300 requests per hour')
120
95
  puts 'Using the URBANopt CLI to submit a Scenario optimization counts as one request per scenario'
121
96
  puts 'Using the URBANopt CLI to submit a Feature optimization counts as one request per feature'
122
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')
@@ -126,7 +101,7 @@ module URBANopt # :nodoc:
126
101
  tries += 1
127
102
  next
128
103
  elsif (result.code != '201') && (result.code != '200') # Anything in the 200s is success
129
- @@logger.warn("REopt-Lite has returned a '#{result.code}' status code. Visit https://developer.nrel.gov/docs/errors/ for more status code information")
104
+ @@logger.warn("REopt has returned a '#{result.code}' status code. Visit https://developer.nrel.gov/docs/errors/ for more status code information")
130
105
  # display error messages
131
106
  json_res = JSON.parse(result.body, allow_nan: true)
132
107
  json_res['messages'].delete('warnings') if json_res['messages']['warnings']
@@ -137,7 +112,7 @@ module URBANopt # :nodoc:
137
112
  end
138
113
  tries = max_tries
139
114
  rescue StandardError => e
140
- @@logger.debug("error from REopt lite API: #{e}")
115
+ @@logger.debug("error from REopt API: #{e}")
141
116
  if tries + 1 < max_tries
142
117
  @@logger.debug('trying again...')
143
118
  else
@@ -151,12 +126,12 @@ module URBANopt # :nodoc:
151
126
  end
152
127
 
153
128
  ##
154
- # Checks if a optimization task can be submitted to the \REopt Lite API
129
+ # Checks if a optimization task can be submitted to the \REopt API
155
130
  ##
156
131
  #
157
132
  # [*parameters:*]
158
133
  #
159
- # * +data+ - _Hash_ - Default \REopt Lite formatted post containing at least all the required parameters.
134
+ # * +data+ - _Hash_ - Default \REopt formatted post containing at least all the required parameters.
160
135
  #
161
136
  # [*return:*] _Bool_ - Returns true if the post succeeeds. Otherwise returns false.
162
137
  ##
@@ -181,15 +156,15 @@ module URBANopt # :nodoc:
181
156
  end
182
157
 
183
158
  ##
184
- # Completes a \REopt Lite optimization. From a formatted hash, an optimization task is submitted to the API.
159
+ # Completes a \REopt optimization. From a formatted hash, an optimization task is submitted to the API.
185
160
  # Results are polled at 5 second interval until they are ready or an error is returned from the API. Results
186
161
  # are written to disk.
187
162
  ##
188
163
  #
189
164
  # [*parameters:*]
190
165
  #
191
- # * +reopt_input+ - _Hash_ - \REopt Lite formatted post containing at least required parameters.
192
- # * +filename+ - _String_ - Path to file that will be created containing the full \REopt Lite response.
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.
193
168
  #
194
169
  # [*return:*] _Bool_ - Returns true if the post succeeeds. Otherwise returns false.
195
170
  ##
@@ -236,7 +211,7 @@ module URBANopt # :nodoc:
236
211
  # If database still hasn't updated, wait a little longer and try again
237
212
  while (elapsed_time < max_elapsed_time) && (response && response.code == '404')
238
213
  response = make_request(http, get_request)
239
- @@logger.warn('GET request was too fast for REOpt-Lite API. Retrying...')
214
+ @@logger.warn('GET request was too fast for REOpt-API. Retrying...')
240
215
  elapsed_time += 5
241
216
  sleep 5
242
217
  end
@@ -261,22 +236,22 @@ module URBANopt # :nodoc:
261
236
  end
262
237
 
263
238
  ##
264
- # Completes a \REopt Lite optimization. From a formatted hash, an optimization task is submitted to the API.
239
+ # Completes a \REopt optimization. From a formatted hash, an optimization task is submitted to the API.
265
240
  # Results are polled at 5 second interval until they are ready or an error is returned from the API. Results
266
241
  # are written to disk.
267
242
  ##
268
243
  #
269
244
  # [*parameters:*]
270
245
  #
271
- # * +reopt_input+ - _Hash_ - \REopt Lite formatted post containing at least required parameters.
272
- # * +filename+ - _String_ - Path to file that will be created containing the full \REopt Lite response.
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.
273
248
  #
274
249
  # [*return:*] _Bool_ - Returns true if the post succeeeds. Otherwise returns false.
275
250
  ##
276
251
  def reopt_request(reopt_input, filename)
277
252
  description = reopt_input[:Scenario][:description]
278
253
 
279
- @@logger.info("Submitting #{description} to REopt Lite API")
254
+ @@logger.info("Submitting #{description} to REopt API")
280
255
 
281
256
  # Format the request
282
257
  header = { 'Content-Type' => 'application/json' }
@@ -291,7 +266,7 @@ module URBANopt # :nodoc:
291
266
  response = make_request(http, post_request)
292
267
  if !response.is_a?(Net::HTTPSuccess)
293
268
  @@logger.error('make_request Failed')
294
- raise 'Check_connection Failed'
269
+ raise 'REopt connection Failed'
295
270
  end
296
271
 
297
272
  # Get UUID
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'logger'
@@ -1,31 +1,6 @@
1
1
  # *********************************************************************************
2
- # URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
2
+ # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
3
+ # See also https://github.com/urbanopt/urbanopt-reopt-gem/blob/develop/LICENSE.md
29
4
  # *********************************************************************************
30
5
 
31
6
  require 'bundler/setup'
@@ -37,16 +12,16 @@ module URBANopt # :nodoc:
37
12
  module REopt # :nodoc:
38
13
  class REoptPostProcessor
39
14
  ##
40
- # \REoptPostProcessor updates a ScenarioReport or FeatureReport based on \REopt Lite optimization response.
15
+ # \REoptPostProcessor updates a ScenarioReport or FeatureReport based on \REopt optimization response.
41
16
  ##
42
17
  #
43
18
  # [*parameters:*]
44
19
  #
45
- # * +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 Lite optimizations.
46
- # * +scenario_reopt_assumptions_file+ - _String_ - Optional. JSON file formatted for a \REopt Lite analysis containing custom input parameters for optimizations at the Scenario Report level
47
- # * +reopt_feature_assumptions+ - _Array_ - Optional. A list of JSON file formatted for a \REopt Lite 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.
48
- # * +use_localhost+ - _Bool_ - If this is true, requests will be sent to a version of the \REopt Lite API running on localhost. Default is false, such that the production version of \REopt Lite is accessed.
49
- # * +nrel_developer_key+ - _String_ - API used to access the \REopt Lite APi. Required only if +localhost+ is false. Obtain from https://developer.nrel.gov/signup/
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/
50
25
  ##
51
26
  def initialize(scenario_report, scenario_reopt_assumptions_file = nil, reopt_feature_assumptions = [], nrel_developer_key = nil, localhost = false)
52
27
  # initialize @@logger
@@ -105,14 +80,14 @@ module URBANopt # :nodoc:
105
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
106
81
 
107
82
  ##
108
- # Updates a FeatureReport based on an optional set of \REopt Lite optimization assumptions.
83
+ # Updates a FeatureReport based on an optional set of \REopt optimization assumptions.
109
84
  ##
110
85
  #
111
86
  # [*parameters:*]
112
87
  #
113
- # * +feature_report+ - _URBANopt::Reporting::DefaultReports::FeatureReport_ - FeatureReport which will be used in creating and then updated by a \REopt Lite opimization response.
114
- # * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt Lite formatted hash containing default parameters (i.e. utility rate, escalation rate) which will be updated by the FeatureReport (i.e. location, roof availability)
115
- # * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt Lite responses will be saved.
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.
116
91
  # * +timeseries_csv_path+ - _String_ - Optional. Path to a file at which the new timeseries CSV for the FeatureReport will be saved.
117
92
  #
118
93
  # [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport
@@ -145,14 +120,14 @@ module URBANopt # :nodoc:
145
120
  end
146
121
 
147
122
  ##
148
- # Updates a ScenarioReport based on an optional set of \REopt Lite optimization assumptions.
123
+ # Updates a ScenarioReport based on an optional set of \REopt optimization assumptions.
149
124
  ##
150
125
  #
151
126
  # [*parameters:*]
152
127
  #
153
- # * +feature_report+ - _URBANopt::Reporting::DefaultReports::ScenarioReport_ - ScenarioReport which will be used in creating and then updated by a \REopt Lite opimization response.
154
- # * +reopt_assumptions_hash+ - _Hash_ - Optional. A \REopt Lite formatted hash containing default parameters (i.e. utility rate, escalation rate) which will be updated by the ScenarioReport (i.e. location, roof availability)
155
- # * +reopt_output_file+ - _String_ - Optional. Path to a file at which REpopt Lite responses will be saved.
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.
156
131
  # * +timeseries_csv_path+ - _String_ - Optional. Path to a file at which the new timeseries CSV for the ScenarioReport will be saved.
157
132
  #
158
133
  # [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ Returns an updated ScenarioReport
@@ -201,14 +176,14 @@ module URBANopt # :nodoc:
201
176
  return result
202
177
  end
203
178
 
204
- # Updates a set of FeatureReports based on an optional set of \REopt Lite optimization assumptions.
179
+ # Updates a set of FeatureReports based on an optional set of \REopt optimization assumptions.
205
180
  ##
206
181
  #
207
182
  # [*parameters:*]
208
183
  #
209
- # * +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 Lite opimization response.
210
- # * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt Lite 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.
211
- # * +reopt_output_files+ - _Array_ - Optional. A array of paths to files at which REpopt Lite responses will be saved. The number and order of the paths should match the feature_reports array.
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.
212
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.
213
188
  #
214
189
  # [*return:*] _Array_ Returns an array of updated _URBANopt::Scenario::DefaultReports::FeatureReport_ objects
@@ -282,7 +257,7 @@ module URBANopt # :nodoc:
282
257
  #
283
258
  # [*parameters:*]
284
259
  #
285
- # * +output_file+ - _Array_ - Optional. An array of paths to files at which REpopt Lite responses will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
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.
286
261
  # [*return:*] _Boolean_ - Returns true if file or nonempty directory exist
287
262
  def output_exists(output_file)
288
263
  res = false
@@ -295,14 +270,14 @@ module URBANopt # :nodoc:
295
270
  return res
296
271
  end
297
272
 
298
- # Updates a ScenarioReport based on an optional set of \REopt Lite optimization assumptions.
273
+ # Updates a ScenarioReport based on an optional set of \REopt optimization assumptions.
299
274
  ##
300
275
  #
301
276
  # [*parameters:*]
302
277
  #
303
- # * +scenario_report+ - _Array_ - A _URBANopt::Reporting::DefaultReports::ScenarioReport_ which will each be used to create (and is subsquently updated by) \REopt Lite opimization responses for each of its FeatureReports.
304
- # * +reopt_assumptions_hashes+ - _Array_ - Optional. An array of \REopt Lite 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.
305
- # * +reopt_output_files+ - _Array_ - Optional. An array of paths to files at which REpopt Lite responses will be saved. The number and order of the paths should match the array in ScenarioReport.feature_reports.
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.
306
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.
307
282
  #
308
283
  # [*return:*] _URBANopt::Scenario::DefaultReports::ScenarioReport_ - Returns an updated ScenarioReport
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "Data Dictionary for REopt Lite Inputs",
3
+ "description": "Data Dictionary for REopt Inputs",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "$ref": "#/definitions/Scenario"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "Data Dictionary for REopt Lite Outputs",
3
+ "description": "Data Dictionary for REopt Outputs",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "$ref": "#/definitions/Response"