openstudio-analysis 1.3.6 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/openstudio-analysis.yml +40 -40
- data/.gitignore +21 -21
- data/.rubocop.yml +9 -9
- data/CHANGELOG.md +274 -269
- data/Gemfile +14 -14
- data/README.md +102 -102
- data/Rakefile +40 -40
- data/lib/openstudio/analysis/algorithm_attributes.rb +47 -47
- data/lib/openstudio/analysis/formulation.rb +881 -857
- data/lib/openstudio/analysis/server_api.rb +862 -862
- data/lib/openstudio/analysis/server_scripts.rb +108 -108
- data/lib/openstudio/analysis/support_files.rb +104 -104
- data/lib/openstudio/analysis/translator/datapoints.rb +454 -454
- data/lib/openstudio/analysis/translator/excel.rb +893 -893
- data/lib/openstudio/analysis/translator/workflow.rb +143 -143
- data/lib/openstudio/analysis/version.rb +12 -12
- data/lib/openstudio/analysis/workflow.rb +302 -279
- data/lib/openstudio/analysis/workflow_step.rb +523 -523
- data/lib/openstudio/analysis.rb +144 -144
- data/lib/openstudio/helpers/hash.rb +10 -10
- data/lib/openstudio/helpers/string.rb +36 -36
- data/lib/openstudio/helpers/utils.rb +36 -36
- data/lib/openstudio/weather/epw.rb +178 -178
- data/lib/openstudio-analysis.rb +47 -47
- data/openstudio-analysis.gemspec +38 -38
- data/update_license.rb +60 -60
- metadata +2 -2
data/README.md
CHANGED
@@ -1,102 +1,102 @@
|
|
1
|
-
# OpenStudio(R) Analysis Gem
|
2
|
-
|
3
|
-
[![Build Status](https://github.com/NREL/OpenStudio-analysis-gem/actions/workflows/openstudio-analysis.yml/badge.svg?branch=develop)](https://github.com/NREL/OpenStudio-analysis-gem/actions/workflows/openstudio-analysis.yml)
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/NREL/OpenStudio-analysis-gem/badge.svg?branch=develop)](https://coveralls.io/r/NREL/OpenStudio-analysis-gem?branch=develop)
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/openstudio-analysis.svg)](https://badge.fury.io/rb/openstudio-analysis)
|
6
|
-
|
7
|
-
The OpenStudio Analysis Gem is used to communicate files to the [OpenStudio Analysis Framework](https://www.tandfonline.com/doi/full/10.1080/19401493.2020.1778788).
|
8
|
-
|
9
|
-
The purpose of this gem is to generate the analysis.json file, analysis.zip, convert an OSW to an OSA, and communicate with the server to upload
|
10
|
-
the simulations.
|
11
|
-
|
12
|
-
This gem does not create the cluster. To manage cloud resources use the [OpenStudio Analysis Framework Helm Charts](https://github.com/NREL/openstudio-server-helm).
|
13
|
-
|
14
|
-
## Instructions
|
15
|
-
|
16
|
-
There are two ways to create an OpenStudio Analysis description:
|
17
|
-
* Use the Excel Translator
|
18
|
-
|
19
|
-
|
20
|
-
* Programmatically
|
21
|
-
|
22
|
-
```
|
23
|
-
analysis = OpenStudio::Analysis.create('Analysis Name')
|
24
|
-
analysis.seed_model = 'local/dir/seed.osm'
|
25
|
-
analysis.weather_file = 'local/dir/USA_CO_Golden-NREL.724666_TMY3.epw'
|
26
|
-
|
27
|
-
# override existing workflow from a file by
|
28
|
-
analysis.workflow = OpenStudio::Analysis::Workflow.load_from_file(...)
|
29
|
-
|
30
|
-
# add measures to the workflow
|
31
|
-
wf = analysis.workflow
|
32
|
-
# def add_measure_from_path(instance_name, instance_display_name, local_path_to_measure)
|
33
|
-
wf.add_measure_from_path('instance_name', 'Display name', 'path_to_measure')
|
34
|
-
wf.add_measure_from_path('instance_name_2', 'Display name two', 'path_to_measure_2')
|
35
|
-
|
36
|
-
# make a measure's argument a variable
|
37
|
-
m = wf.add_measure_from_path('instance_name_3', 'Display name three', 'path_to_measure_3')
|
38
|
-
m.make_variable('variable_argument_name', 'discrete')
|
39
|
-
|
40
|
-
m = wf.add_measure_from_path('instance_name_4', 'Display name four', 'path_to_measure_4')
|
41
|
-
m.make_variable('variable_argument_name', 'pivot')
|
42
|
-
m.argument_value('variable_argument_name', value)
|
43
|
-
|
44
|
-
# Save off the analysis files and a static data point
|
45
|
-
run_dir = 'local/run'
|
46
|
-
analysis.save("#{run_dir}/analysis.json")
|
47
|
-
analysis.save_zip("#{run_dir}/analysis.zip")
|
48
|
-
analysis.save_static_data_point("#{run_dir}/data_point.zip")
|
49
|
-
```
|
50
|
-
|
51
|
-
* Running Datapoints with Workflow Gem
|
52
|
-
|
53
|
-
```
|
54
|
-
require 'openstudio-workflow'
|
55
|
-
|
56
|
-
run_dir = 'local/run'
|
57
|
-
OpenStudio::Workflow.extract_archive("#{run_dir}/analysis.zip", run_dir)
|
58
|
-
|
59
|
-
options = {
|
60
|
-
problem_filename: 'analysis.json',
|
61
|
-
datapoint_filename: 'data_point.json',
|
62
|
-
analysis_root_path: run_dir
|
63
|
-
}
|
64
|
-
k = OpenStudio::Workflow.load 'Local', run_dir, options
|
65
|
-
k.run
|
66
|
-
```
|
67
|
-
|
68
|
-
* Server API
|
69
|
-
|
70
|
-
## Testing
|
71
|
-
|
72
|
-
This gem used RSpec for testing. To test simply run `bundle exec rspec` at the command line.
|
73
|
-
|
74
|
-
# Releasing
|
75
|
-
|
76
|
-
Follow the steps below when releasing a new version:
|
77
|
-
|
78
|
-
1. Update /lib/openstudio/analysis/version.rb to the next version. Make sure to follow semantic versioning.
|
79
|
-
2. Add changes to the CHANGELOG.md.
|
80
|
-
3. Run rubocop and make sure code meets coding standards.
|
81
|
-
4. Push release candidate on a branch.
|
82
|
-
5. Create a pull request to develop. Once the tests pass, merge into develop.
|
83
|
-
6. Create a pull request to main. Once tests pass, then merge into main.
|
84
|
-
7. Checkout main and run `rake release`
|
85
|
-
|
86
|
-
# Todos
|
87
|
-
|
88
|
-
In the programmatic interface there are still several items that would be nice to have.
|
89
|
-
|
90
|
-
* Check the type of measure being added and make sure that it is in the right workflow (e.g. no energyplus measures before rubymeasures)
|
91
|
-
* add reverse translator from existing analysis.jsons
|
92
|
-
* more explicit run workflows. For example, add workflow steps for running energyplus, openstudio translator, radiance, etc
|
93
|
-
* more explicit assignment of the analyses that can run. This would be nice:
|
94
|
-
|
95
|
-
```
|
96
|
-
a = OpenStudio::Analysis.create("new analysis")
|
97
|
-
a.analysis_type('single_run')
|
98
|
-
```
|
99
|
-
|
100
|
-
* adding mulitple seed models
|
101
|
-
* adding multiple weather files
|
102
|
-
|
1
|
+
# OpenStudio(R) Analysis Gem
|
2
|
+
|
3
|
+
[![Build Status](https://github.com/NREL/OpenStudio-analysis-gem/actions/workflows/openstudio-analysis.yml/badge.svg?branch=develop)](https://github.com/NREL/OpenStudio-analysis-gem/actions/workflows/openstudio-analysis.yml)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/NREL/OpenStudio-analysis-gem/badge.svg?branch=develop)](https://coveralls.io/r/NREL/OpenStudio-analysis-gem?branch=develop)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/openstudio-analysis.svg)](https://badge.fury.io/rb/openstudio-analysis)
|
6
|
+
|
7
|
+
The OpenStudio Analysis Gem is used to communicate files to the [OpenStudio Analysis Framework](https://www.tandfonline.com/doi/full/10.1080/19401493.2020.1778788).
|
8
|
+
|
9
|
+
The purpose of this gem is to generate the analysis.json file, analysis.zip, convert an OSW to an OSA, and communicate with the server to upload
|
10
|
+
the simulations.
|
11
|
+
|
12
|
+
This gem does not create the cluster. To manage cloud resources use the [OpenStudio Analysis Framework Helm Charts](https://github.com/NREL/openstudio-server-helm).
|
13
|
+
|
14
|
+
## Instructions
|
15
|
+
|
16
|
+
There are two ways to create an OpenStudio Analysis description:
|
17
|
+
* Use the Excel Translator
|
18
|
+
|
19
|
+
|
20
|
+
* Programmatically
|
21
|
+
|
22
|
+
```
|
23
|
+
analysis = OpenStudio::Analysis.create('Analysis Name')
|
24
|
+
analysis.seed_model = 'local/dir/seed.osm'
|
25
|
+
analysis.weather_file = 'local/dir/USA_CO_Golden-NREL.724666_TMY3.epw'
|
26
|
+
|
27
|
+
# override existing workflow from a file by
|
28
|
+
analysis.workflow = OpenStudio::Analysis::Workflow.load_from_file(...)
|
29
|
+
|
30
|
+
# add measures to the workflow
|
31
|
+
wf = analysis.workflow
|
32
|
+
# def add_measure_from_path(instance_name, instance_display_name, local_path_to_measure)
|
33
|
+
wf.add_measure_from_path('instance_name', 'Display name', 'path_to_measure')
|
34
|
+
wf.add_measure_from_path('instance_name_2', 'Display name two', 'path_to_measure_2')
|
35
|
+
|
36
|
+
# make a measure's argument a variable
|
37
|
+
m = wf.add_measure_from_path('instance_name_3', 'Display name three', 'path_to_measure_3')
|
38
|
+
m.make_variable('variable_argument_name', 'discrete')
|
39
|
+
|
40
|
+
m = wf.add_measure_from_path('instance_name_4', 'Display name four', 'path_to_measure_4')
|
41
|
+
m.make_variable('variable_argument_name', 'pivot')
|
42
|
+
m.argument_value('variable_argument_name', value)
|
43
|
+
|
44
|
+
# Save off the analysis files and a static data point
|
45
|
+
run_dir = 'local/run'
|
46
|
+
analysis.save("#{run_dir}/analysis.json")
|
47
|
+
analysis.save_zip("#{run_dir}/analysis.zip")
|
48
|
+
analysis.save_static_data_point("#{run_dir}/data_point.zip")
|
49
|
+
```
|
50
|
+
|
51
|
+
* Running Datapoints with Workflow Gem
|
52
|
+
|
53
|
+
```
|
54
|
+
require 'openstudio-workflow'
|
55
|
+
|
56
|
+
run_dir = 'local/run'
|
57
|
+
OpenStudio::Workflow.extract_archive("#{run_dir}/analysis.zip", run_dir)
|
58
|
+
|
59
|
+
options = {
|
60
|
+
problem_filename: 'analysis.json',
|
61
|
+
datapoint_filename: 'data_point.json',
|
62
|
+
analysis_root_path: run_dir
|
63
|
+
}
|
64
|
+
k = OpenStudio::Workflow.load 'Local', run_dir, options
|
65
|
+
k.run
|
66
|
+
```
|
67
|
+
|
68
|
+
* Server API
|
69
|
+
|
70
|
+
## Testing
|
71
|
+
|
72
|
+
This gem used RSpec for testing. To test simply run `bundle exec rspec` at the command line.
|
73
|
+
|
74
|
+
# Releasing
|
75
|
+
|
76
|
+
Follow the steps below when releasing a new version:
|
77
|
+
|
78
|
+
1. Update /lib/openstudio/analysis/version.rb to the next version. Make sure to follow semantic versioning.
|
79
|
+
2. Add changes to the CHANGELOG.md.
|
80
|
+
3. Run rubocop and make sure code meets coding standards.
|
81
|
+
4. Push release candidate on a branch.
|
82
|
+
5. Create a pull request to develop. Once the tests pass, merge into develop.
|
83
|
+
6. Create a pull request to main. Once tests pass, then merge into main.
|
84
|
+
7. Checkout main and run `rake release`
|
85
|
+
|
86
|
+
# Todos
|
87
|
+
|
88
|
+
In the programmatic interface there are still several items that would be nice to have.
|
89
|
+
|
90
|
+
* Check the type of measure being added and make sure that it is in the right workflow (e.g. no energyplus measures before rubymeasures)
|
91
|
+
* add reverse translator from existing analysis.jsons
|
92
|
+
* more explicit run workflows. For example, add workflow steps for running energyplus, openstudio translator, radiance, etc
|
93
|
+
* more explicit assignment of the analyses that can run. This would be nice:
|
94
|
+
|
95
|
+
```
|
96
|
+
a = OpenStudio::Analysis.create("new analysis")
|
97
|
+
a.analysis_type('single_run')
|
98
|
+
```
|
99
|
+
|
100
|
+
* adding mulitple seed models
|
101
|
+
* adding multiple weather files
|
102
|
+
|
data/Rakefile
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
-
# See also https://openstudio.net/license
|
4
|
-
# *******************************************************************************
|
5
|
-
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
|
-
|
9
|
-
require 'rspec/core/rake_task'
|
10
|
-
|
11
|
-
# Always create spec reports
|
12
|
-
require 'ci/reporter/rake/rspec'
|
13
|
-
|
14
|
-
# Gem tasks
|
15
|
-
require 'bundler/gem_tasks'
|
16
|
-
|
17
|
-
RSpec::Core::RakeTask.new('spec:unit') do |spec|
|
18
|
-
spec.rspec_opts = ['--format', 'progress']
|
19
|
-
spec.pattern = FileList['spec/openstudio/**/*_spec.rb']
|
20
|
-
end
|
21
|
-
|
22
|
-
RSpec::Core::RakeTask.new('spec:integration') do |spec|
|
23
|
-
spec.rspec_opts = ['--format', 'progress']
|
24
|
-
spec.pattern = FileList['spec/integration/**/*_spec.rb']
|
25
|
-
end
|
26
|
-
|
27
|
-
task 'spec:unit' => 'ci:setup:rspec'
|
28
|
-
task 'spec:integration' => 'ci:setup:rspec'
|
29
|
-
|
30
|
-
task default: 'spec:unit'
|
31
|
-
|
32
|
-
require 'rubocop/rake_task'
|
33
|
-
desc 'Run RuboCop on the lib directory'
|
34
|
-
RuboCop::RakeTask.new(:rubocop) do |task|
|
35
|
-
task.options = ['--no-color', '--out=rubocop-results.xml', '--format', 'simple']
|
36
|
-
task.formatters = ['RuboCop::Formatter::CheckstyleFormatter']
|
37
|
-
task.requires = ['rubocop/formatter/checkstyle_formatter']
|
38
|
-
# don't abort rake on failure
|
39
|
-
task.fail_on_error = false
|
40
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
4
|
+
# *******************************************************************************
|
5
|
+
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.setup
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
|
11
|
+
# Always create spec reports
|
12
|
+
require 'ci/reporter/rake/rspec'
|
13
|
+
|
14
|
+
# Gem tasks
|
15
|
+
require 'bundler/gem_tasks'
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new('spec:unit') do |spec|
|
18
|
+
spec.rspec_opts = ['--format', 'progress']
|
19
|
+
spec.pattern = FileList['spec/openstudio/**/*_spec.rb']
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec::Core::RakeTask.new('spec:integration') do |spec|
|
23
|
+
spec.rspec_opts = ['--format', 'progress']
|
24
|
+
spec.pattern = FileList['spec/integration/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
task 'spec:unit' => 'ci:setup:rspec'
|
28
|
+
task 'spec:integration' => 'ci:setup:rspec'
|
29
|
+
|
30
|
+
task default: 'spec:unit'
|
31
|
+
|
32
|
+
require 'rubocop/rake_task'
|
33
|
+
desc 'Run RuboCop on the lib directory'
|
34
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
35
|
+
task.options = ['--no-color', '--out=rubocop-results.xml', '--format', 'simple']
|
36
|
+
task.formatters = ['RuboCop::Formatter::CheckstyleFormatter']
|
37
|
+
task.requires = ['rubocop/formatter/checkstyle_formatter']
|
38
|
+
# don't abort rake on failure
|
39
|
+
task.fail_on_error = false
|
40
|
+
end
|
@@ -1,47 +1,47 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
-
# See also https://openstudio.net/license
|
4
|
-
# *******************************************************************************
|
5
|
-
|
6
|
-
# OpenStudio::Analysis::Algorithm define the algorithm parameters. The module and class names start to conflict
|
7
|
-
# with OpenStudio's namespace. Be careful adding new classes without first making sure that the namespace conflict
|
8
|
-
# is clear.
|
9
|
-
module OpenStudio
|
10
|
-
module Analysis
|
11
|
-
class AlgorithmAttributes
|
12
|
-
# Create a new instance of the parameters for an algorithm
|
13
|
-
#
|
14
|
-
def initialize
|
15
|
-
@attributes = {
|
16
|
-
"seed": nil,
|
17
|
-
"failed_f_value": 1000000000000000000,
|
18
|
-
"debug_messages": 1
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
# these are the allowed analysis types
|
23
|
-
ANALYSIS_TYPES = ['diag', 'doe', 'fast99', 'ga', 'gaisl', 'lhs', 'morris', 'nsga_nrel', 'optim',
|
24
|
-
'preflight', 'pso', 'repeat_run', 'rgenoud', 'single_run', 'sobol', 'spea_nrel']
|
25
|
-
|
26
|
-
def set_attribute(attribute_name, attribute_value)
|
27
|
-
@attributes[attribute_name] = attribute_value
|
28
|
-
begin
|
29
|
-
unless Float(attribute_value).nil?
|
30
|
-
if Float(attribute_value).abs >= Float('1.0e+19')
|
31
|
-
raise "ERROR: Attribute `#{attribute_name}` is greater than 1E19. This may cause failures."
|
32
|
-
end
|
33
|
-
end
|
34
|
-
rescue ArgumentError, TypeError
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def [](name)
|
39
|
-
@attributes[name]
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_hash(_version = 1)
|
43
|
-
@attributes
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
4
|
+
# *******************************************************************************
|
5
|
+
|
6
|
+
# OpenStudio::Analysis::Algorithm define the algorithm parameters. The module and class names start to conflict
|
7
|
+
# with OpenStudio's namespace. Be careful adding new classes without first making sure that the namespace conflict
|
8
|
+
# is clear.
|
9
|
+
module OpenStudio
|
10
|
+
module Analysis
|
11
|
+
class AlgorithmAttributes
|
12
|
+
# Create a new instance of the parameters for an algorithm
|
13
|
+
#
|
14
|
+
def initialize
|
15
|
+
@attributes = {
|
16
|
+
"seed": nil,
|
17
|
+
"failed_f_value": 1000000000000000000,
|
18
|
+
"debug_messages": 1
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# these are the allowed analysis types
|
23
|
+
ANALYSIS_TYPES = ['diag', 'doe', 'fast99', 'ga', 'gaisl', 'lhs', 'morris', 'nsga_nrel', 'optim',
|
24
|
+
'preflight', 'pso', 'repeat_run', 'rgenoud', 'single_run', 'sobol', 'spea_nrel']
|
25
|
+
|
26
|
+
def set_attribute(attribute_name, attribute_value)
|
27
|
+
@attributes[attribute_name] = attribute_value
|
28
|
+
begin
|
29
|
+
unless Float(attribute_value).nil?
|
30
|
+
if Float(attribute_value).abs >= Float('1.0e+19')
|
31
|
+
raise "ERROR: Attribute `#{attribute_name}` is greater than 1E19. This may cause failures."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue ArgumentError, TypeError
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def [](name)
|
39
|
+
@attributes[name]
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_hash(_version = 1)
|
43
|
+
@attributes
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|