openstudio-analysis 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -6
  3. data/README.md +55 -7
  4. data/Rakefile +10 -0
  5. data/lib/openstudio/analysis/algorithm_attributes.rb +22 -0
  6. data/lib/openstudio/analysis/formulation.rb +174 -0
  7. data/lib/openstudio/analysis/translator/excel.rb +65 -48
  8. data/lib/openstudio/analysis/version.rb +1 -1
  9. data/lib/openstudio/analysis/workflow.rb +197 -0
  10. data/lib/openstudio/analysis/workflow_step.rb +312 -0
  11. data/lib/openstudio/analysis.rb +8 -0
  12. data/lib/openstudio/helpers/string.rb +22 -22
  13. data/lib/openstudio/templates/analysis.json.erb +0 -1
  14. data/lib/openstudio-analysis.rb +9 -0
  15. data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
  16. data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
  17. data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
  18. data/spec/files/analysis/example_analysis_api.json +656 -0
  19. data/spec/files/analysis/examples/discrete_lhs_example.json +809 -0
  20. data/spec/files/analysis/examples/medium_office_example.json +1673 -0
  21. data/spec/files/analysis/lhs_discrete_and_continuous_variables_api.json +1230 -0
  22. data/spec/files/analysis/medium_office.json +91 -92
  23. data/spec/files/analysis/medium_office.zip +0 -0
  24. data/spec/files/analysis/name_goes_here_api.json +1681 -0
  25. data/spec/files/analysis/output_vars_api.json +632 -0
  26. data/spec/files/analysis/preflight_api.json +1518 -0
  27. data/spec/files/analysis/simple_test_api.json +519 -0
  28. data/spec/files/analysis/test_model_api.json +493 -0
  29. data/spec/files/export/analysis/0_1_09_outputvars.json +38 -39
  30. data/spec/files/export/analysis/0_1_09_outputvars.zip +0 -0
  31. data/spec/files/export/analysis/0_1_11_discrete_variables.json +46 -47
  32. data/spec/files/export/analysis/0_1_11_discrete_variables.zip +0 -0
  33. data/spec/files/export/analysis/0_1_12_discrete_dynamic_columns.json +8 -9
  34. data/spec/files/export/analysis/0_1_12_discrete_dynamic_columns.zip +0 -0
  35. data/spec/files/export/analysis/0_2_0_template_simpletest.json +19 -14
  36. data/spec/files/export/analysis/0_2_0_template_simpletest.zip +0 -0
  37. data/spec/files/export/analysis/0_3_0_outputs.json +99 -100
  38. data/spec/files/export/analysis/0_3_0_outputs.zip +0 -0
  39. data/spec/files/export/analysis/{6d6a08db-fdf8-4bb5-8ad3-18c471418c72.json → 276ccf51-ed22-4604-a380-8985cec5efe8.json} +103 -104
  40. data/spec/files/export/analysis/{6d6a08db-fdf8-4bb5-8ad3-18c471418c72.zip → 276ccf51-ed22-4604-a380-8985cec5efe8.zip} +0 -0
  41. data/spec/files/export/analysis/{55086845-70cf-487f-87f6-7a147cbf1e72.json → 639cb8a5-cdbb-4b69-955a-cbb650f6872b.json} +107 -108
  42. data/spec/files/export/analysis/{55086845-70cf-487f-87f6-7a147cbf1e72.zip → 639cb8a5-cdbb-4b69-955a-cbb650f6872b.zip} +0 -0
  43. data/spec/files/export/analysis/{10c791ce-cba7-4506-a863-3fb15703889b.json → 9560f95b-5730-4038-a95b-328c825c596b.json} +99 -100
  44. data/spec/files/export/analysis/{10c791ce-cba7-4506-a863-3fb15703889b.zip → 9560f95b-5730-4038-a95b-328c825c596b.zip} +0 -0
  45. data/spec/files/export/analysis/{f028bfbe-e30e-488d-adad-a60a62bbf7e0.json → c50f0062-cdfb-4dec-bc02-215f6c29af3c.json} +107 -108
  46. data/spec/files/export/analysis/{f028bfbe-e30e-488d-adad-a60a62bbf7e0.zip → c50f0062-cdfb-4dec-bc02-215f6c29af3c.zip} +0 -0
  47. data/spec/files/export/analysis/discrete_lhs_example.json +1185 -0
  48. data/spec/files/export/analysis/discrete_lhs_example.zip +0 -0
  49. data/spec/files/export/analysis/small_seed.json +38 -39
  50. data/spec/files/export/analysis/small_seed.zip +0 -0
  51. data/spec/files/export/workflow/analysis.json +23 -0
  52. data/spec/files/measures/ActualMeasureNoJson/measure.json +25 -0
  53. data/spec/files/measures/ActualMeasureNoJson/measure.rb +80 -0
  54. data/spec/files/measures/ActualMeasureNoJson/measure.xml +2 -0
  55. data/spec/files/measures/SetThermostatSchedules/measure.json +63 -0
  56. data/spec/files/measures/SetThermostatSchedules/measure.rb +254 -0
  57. data/spec/files/measures/SetThermostatSchedules/measure.xml +2 -0
  58. data/spec/openstudio/excel_spec.rb +11 -11
  59. data/spec/openstudio/formulation_spec.rb +107 -0
  60. data/spec/openstudio/workflow_spec.rb +90 -0
  61. data/spec/openstudio/workflow_step_spec.rb +116 -0
  62. data/spec/reports/SPEC-OpenStudio-Analysis-Formulation.xml +28 -0
  63. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-create-a-new-object-instance.xml +2 -2
  64. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-test-not-localhost.xml +2 -2
  65. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi.xml +1 -1
  66. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-variables.xml +30 -4
  67. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-with-dynamic-columns.xml +11 -3
  68. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-no-variables-defined.xml +6 -6
  69. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup-with-user.xml +2 -2
  70. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup.xml +2 -2
  71. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-output-variables.xml +52 -8
  72. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-version-0-1-9.xml +22 -5
  73. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-incomplete-variables.xml +2 -2
  74. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables-should-not-validate.xml +2 -2
  75. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables.xml +28 -5
  76. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-with-with-repeated-variable-names.xml +2 -2
  77. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-1-10.xml +3 -3
  78. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0-simple.xml +13 -6
  79. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0.xml +55 -5
  80. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-0-dynamic-uuid-assignments.xml +9 -4
  81. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-0-measure-existence-checks.xml +8 -3
  82. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-0-objective-functions.xml +13 -5
  83. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-3-and-short-display-names.xml +9 -4
  84. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-5-and-measure-paths.xml +9 -4
  85. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-7-and-worker-init-final-scripts.0.xml +40 -2
  86. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-7-and-worker-init-final-scripts.xml +9 -4
  87. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel.xml +1 -1
  88. data/spec/reports/SPEC-OpenStudio-Analysis-Workflow.xml +31 -0
  89. data/spec/reports/SPEC-OpenStudio-Analysis-WorkflowStep.xml +29 -0
  90. data/spec/spec_helper.rb +1 -1
  91. metadata +87 -18
@@ -104,7 +104,6 @@ describe OpenStudio::Analysis::Translator::Excel do
104
104
  expect(File).to exist('spec/files/export/analysis/small_seed.zip')
105
105
 
106
106
  expect(JSON.parse(File.read('spec/files/export/analysis/small_seed.json'))).not_to be_nil
107
-
108
107
  end
109
108
  end
110
109
 
@@ -129,7 +128,6 @@ describe OpenStudio::Analysis::Translator::Excel do
129
128
  expect(@excel.algorithm['number_of_generations']).to be_a Integer
130
129
  expect(@excel.algorithm['tolerance']).to eq(0.115)
131
130
  expect(@excel.algorithm['tolerance']).to be_a Float
132
-
133
131
  end
134
132
 
135
133
  it 'should create a valid hash' do
@@ -181,8 +179,8 @@ describe OpenStudio::Analysis::Translator::Excel do
181
179
  if var['name'] == 'alter_design_days'
182
180
  puts var.inspect
183
181
  expect(var['type']).to eq 'bool'
184
- expect(eval(var['distribution']['discrete_values'])).to match_array %w(true false)
185
- expect(eval(var['distribution']['discrete_weights'])).to match_array [0.8, 0.2]
182
+ expect(var['distribution']['discrete_values']).to match_array [true, false]
183
+ expect(var['distribution']['discrete_weights']).to match_array [0.8, 0.2]
186
184
  end
187
185
  end
188
186
  end
@@ -257,7 +255,6 @@ describe OpenStudio::Analysis::Translator::Excel do
257
255
  expect(@excel.algorithm['number_of_generations']).to be_a Integer
258
256
  # expect(@excel.algorithm["tolerance"]).to eq(0.115)
259
257
  # expect(@excel.algorithm["tolerance"]).to be_a Float
260
-
261
258
  end
262
259
 
263
260
  it 'should create a valid hash' do
@@ -372,7 +369,7 @@ describe OpenStudio::Analysis::Translator::Excel do
372
369
  expect(h['analysis']['output_variables']).to be_an Array
373
370
  h['analysis']['output_variables'].each do |o|
374
371
  if o['name'] == 'standard_report_legacy.total_energy'
375
- expect(o['variable_type']).to eq 'Double'
372
+ expect(o['variable_type']).to eq 'double'
376
373
  expect(o['objective_function']).to eq true
377
374
  expect(o['objective_function_index']).to eq 0
378
375
  expect(o['objective_function_target']).to eq nil
@@ -380,7 +377,7 @@ describe OpenStudio::Analysis::Translator::Excel do
380
377
  expect(o['objective_function_group']).to eq 1
381
378
  end
382
379
  if o['name'] == 'standard_report_legacy.total_source_energy'
383
- expect(o['variable_type']).to eq 'Double'
380
+ expect(o['variable_type']).to eq 'double'
384
381
  expect(o['objective_function']).to eq true
385
382
  expect(o['objective_function_index']).to eq 1
386
383
  expect(o['objective_function_target']).to eq 25.1
@@ -530,19 +527,22 @@ describe OpenStudio::Analysis::Translator::Excel do
530
527
 
531
528
  expect(@excel.worker_finals.size).to eq 1
532
529
  expect(@excel.worker_inits[0][:ordered_file_name]).to eq '00_first_file.rb'
533
-
534
530
  end
535
531
  end
536
532
 
537
533
  context 'version 0.3.7 and worker init-final scripts' do
538
534
  before :all do
539
- @excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_7_unique_measure_names.xlsx')
535
+ @excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_4_0_lhs_discrete_continuous.xlsx')
540
536
  end
541
537
 
542
538
  it 'should fail to process' do
543
- expect { @excel.process }.to raise_error("Measure Display Names are not unique for 'Rotate Building Relative to Current Orientation', 'Nothing Important'")
544
- end
539
+ @excel.process
540
+ # expect { @excel.process }.to raise_error("Measure Display Names are not unique for 'Rotate Building Relative to Current Orientation', 'Nothing Important'")
545
541
 
542
+ @excel.save_analysis
543
+ end
546
544
  end
547
545
 
546
+ context 'version 0.4.0 full spreadsheet example' do
547
+ end
548
548
  end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudio::Analysis::Formulation do
4
+ it 'should create an analysis' do
5
+ a = OpenStudio::Analysis.create('Name of an analysis')
6
+ expect(a).not_to be nil
7
+ expect(a.display_name).to eq 'Name of an analysis'
8
+ expect(a).to be_a OpenStudio::Analysis::Formulation
9
+ end
10
+
11
+ it 'should have a workflow object' do
12
+ a = OpenStudio::Analysis.create('workflow')
13
+ expect(a.workflow).not_to be nil
14
+ end
15
+
16
+ it 'should load the workflow from a file' do
17
+ a = OpenStudio::Analysis.create('workflow')
18
+ file = File.join('spec/files/analysis/examples/medium_office_example.json')
19
+ expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
20
+ end
21
+
22
+ it 'should save a hash (version 1)' do
23
+ a = OpenStudio::Analysis.create('workflow 2')
24
+ file = File.join('spec/files/analysis/examples/medium_office_example.json')
25
+ expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
26
+ h = a.to_hash
27
+ # expect(h[:workflow].empty?).not_to eq true
28
+ end
29
+
30
+ it 'should create a save an empty analysis' do
31
+ a = OpenStudio::Analysis.create('workflow')
32
+ run_dir = 'spec/files/export/workflow'
33
+
34
+ FileUtils.mkdir_p run_dir
35
+
36
+ h = a.to_hash
37
+ expect(h[:analysis][:problem][:analysis_type]).to eq nil
38
+ expect(a.save "#{run_dir}/analysis.json").to eq true
39
+ end
40
+
41
+ it 'should increment objective functions' do
42
+ a = OpenStudio::Analysis.create('my analysis')
43
+
44
+ a.add_output(
45
+ display_name: 'Total Natural Gas',
46
+ name: 'standard_report_legacy.total_natural_gas',
47
+ units: 'MJ/m2',
48
+ objective_function: true
49
+ )
50
+
51
+ expect(a.to_hash[:analysis][:output_variables].first[:objective_function_index]).to eq 0
52
+
53
+ a.add_output(
54
+ display_name: 'Another Output',
55
+ name: 'standard_report_legacy.output_2',
56
+ units: 'MJ/m2',
57
+ objective_function: true
58
+ )
59
+ expect(a.to_hash[:analysis][:output_variables].last[:objective_function_index]).to eq 1
60
+ end
61
+
62
+ it 'should create a new formulation' do
63
+ a = OpenStudio::Analysis.create('my analysis')
64
+ p = 'spec/files/measures/SetThermostatSchedules'
65
+
66
+ a.workflow.add_measure_from_path('thermostat', 'thermostat', p)
67
+ m = a.workflow.add_measure_from_path('thermostat_2', 'thermostat 2', p)
68
+
69
+ d = {
70
+ type: 'uniform',
71
+ minimum: 5,
72
+ maximum: 7,
73
+ mean: 6.2
74
+ }
75
+ m.make_variable('cooling_sch', 'Change the cooling schedule', d)
76
+ m.argument_value('heating_sch', 'some-string')
77
+
78
+ expect(a.workflow.measures.size).to eq 2
79
+ expect(a.workflow.measures[1].arguments[2][:value]).to eq 'some-string'
80
+ expect(a.workflow.measures[1].variables[0][:uuid]).to match /[\w]{8}(-[\w]{4}){3}-[\w]{12}/
81
+
82
+ a.analysis_type = 'single_run'
83
+ a.algorithm.set_attribute('sample_method', 'all_variables')
84
+ o = {
85
+ display_name: 'Total Natural Gas',
86
+ display_name_short: 'Total Natural Gas',
87
+ metadata_id: nil,
88
+ name: 'total_natural_gas',
89
+ units: 'MJ/m2',
90
+ objective_function: true,
91
+ objective_function_index: 0,
92
+ objective_function_target: 330.7,
93
+ scaling_factor: nil,
94
+ objective_function_group: nil
95
+ }
96
+ a.add_output(o)
97
+
98
+ a.seed_model('spec/files/small_seed.osm')
99
+ a.weather_file('spec/files/partial_weather.epw')
100
+
101
+ expect(a.to_hash[:analysis][:problem][:algorithm][:objective_functions]).to match ['total_natural_gas']
102
+ expect(a.analysis_type).to eq 'single_run'
103
+
104
+ dp_hash = a.to_static_data_point_hash
105
+ expect(dp_hash[:data_point][:set_variable_values].values).to eq ['*No Change*']
106
+ end
107
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudio::Analysis::Workflow do
4
+ before :all do
5
+ @w = OpenStudio::Analysis::Workflow.new
6
+ end
7
+
8
+ it 'should create a workflow' do
9
+ expect(@w).not_to be nil
10
+ expect(@w).to be_a OpenStudio::Analysis::Workflow
11
+ end
12
+
13
+ it 'should add a measure' do
14
+ p = 'spec/files/measures/IncreaseInsulationRValueForRoofs'
15
+ expect(@w.add_measure_from_path('insulation', 'Increase Insulation', p)).to be_an OpenStudio::Analysis::WorkflowStep
16
+
17
+ p = 'spec/files/measures/ActualMeasureNoJson'
18
+ FileUtils.remove "#{p}/measure.json" if File.exist? "#{p}/measure.json"
19
+ m = @w.add_measure_from_path('a_measure', 'Actual Measure', p)
20
+ expect(m).to be_a OpenStudio::Analysis::WorkflowStep
21
+ expect(m.measure_definition_class_name).to eq 'RotateBuilding'
22
+ end
23
+
24
+ it 'should fix the path of the measure' do
25
+ p = 'spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb'
26
+ m = @w.add_measure_from_path('insulation', 'Increase Insulation', p)
27
+ expect(m).to be_an OpenStudio::Analysis::WorkflowStep
28
+ expect(m.measure_definition_directory).to eq 'spec/files/measures/IncreaseInsulationRValueForRoofs'
29
+ end
30
+
31
+ it 'should clear out a workflow' do
32
+ p = 'spec/files/measures/SetThermostatSchedules'
33
+ @w.add_measure_from_path('thermostat', 'thermostat', p)
34
+ @w.add_measure_from_path('thermostat 2', 'thermostat 2', p)
35
+
36
+ expect(@w.items.size).to be > 1
37
+ @w.clear
38
+ expect(@w.items.size).to eq 0
39
+
40
+ @w.add_measure_from_path('thermostat', 'thermostat', p)
41
+ @w.add_measure_from_path('thermostat 2', 'thermostat 2', p)
42
+ expect(@w.items.size).to eq 2
43
+ end
44
+
45
+ it 'should find a workflow step' do
46
+ @w.clear
47
+
48
+ p = 'spec/files/measures/SetThermostatSchedules'
49
+ @w.add_measure_from_path('thermostat', 'thermostat', p)
50
+ @w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
51
+
52
+ m = @w.find_measure('thermostat_2')
53
+ expect(m).not_to be nil
54
+ expect(m).to be_a OpenStudio::Analysis::WorkflowStep
55
+ expect(m.name).to eq 'thermostat_2'
56
+ end
57
+
58
+ it 'should find a workflow step and make a variable' do
59
+ @w.clear
60
+
61
+ p = 'spec/files/measures/SetThermostatSchedules'
62
+ @w.add_measure_from_path('thermostat', 'thermostat', p)
63
+ @w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
64
+
65
+ m = @w.find_measure('thermostat_2')
66
+ expect(m.argument_names).to eq %w(zones cooling_sch heating_sch material_cost)
67
+
68
+ d = {
69
+ type: 'uniform',
70
+ minimum: 5,
71
+ maximum: 7,
72
+ mean: 6.2
73
+ }
74
+ m.make_variable('cooling_sch', 'Change the cooling schedule', d)
75
+
76
+ d = {
77
+ type: 'uniform',
78
+ minimum: 5,
79
+ maximum: 7,
80
+ mean: 6.2
81
+ }
82
+ m.make_variable('heating_sch', 'Change the heating schedule', d)
83
+
84
+ expect(@w.measures.size).to eq 2
85
+ expect(@w.items.size).to eq 2
86
+ expect(@w.items.size).to eq 2
87
+
88
+ expect(@w.all_variables.size).to eq 2
89
+ end
90
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudio::Analysis::WorkflowStep do
4
+ it 'should create a workflow' do
5
+ s = OpenStudio::Analysis::WorkflowStep.new
6
+ expect(s).not_to be nil
7
+ expect(s).to be_a OpenStudio::Analysis::WorkflowStep
8
+ end
9
+
10
+ it 'should add a measure' do
11
+ h = 'spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json'
12
+ s = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
13
+ 'my_instance',
14
+ 'my instance display name',
15
+ h,
16
+ JSON.parse(File.read(h), symbolize_names: true))
17
+ puts s
18
+ end
19
+
20
+ it 'should tag a discrete variable' do
21
+ h = 'spec/files/measures/SetThermostatSchedules/measure.json'
22
+ measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
23
+ 'my_instance',
24
+ 'my instance display name',
25
+ h,
26
+ JSON.parse(File.read(h), symbolize_names: true))
27
+
28
+ expect(measure.name).to eq 'my_instance'
29
+ v = {
30
+ type: 'discrete',
31
+ minimum: 'low string',
32
+ maximum: 'high string',
33
+ mean: 'middle string',
34
+ values: %w(a b c d),
35
+ weights: [0.25, 0.25, 0.25, 0.25]
36
+ }
37
+ r = measure.make_variable('cooling_sch', 'my variable', v)
38
+ expect(r).to eq true
39
+ end
40
+
41
+ it 'should tag a continuous variable' do
42
+ h = 'spec/files/measures/SetThermostatSchedules/measure.json'
43
+ measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
44
+ 'my_instance',
45
+ 'my instance display name',
46
+ h,
47
+ JSON.parse(File.read(h), symbolize_names: true))
48
+
49
+ expect(measure.name).to eq 'my_instance'
50
+ v = {
51
+ type: 'triangle',
52
+ minimum: 0.5,
53
+ maximum: 20,
54
+ mean: 10,
55
+ static_value: 24601
56
+ }
57
+ r = measure.make_variable('cooling_sch', 'my variable', v)
58
+
59
+ h = measure.to_hash
60
+
61
+ expect(h[:variables].first[:static_value]).to eq 24601
62
+ expect(h[:variables].first.key?(:step_size)).to eq false
63
+
64
+ expect(r).to eq true
65
+ end
66
+
67
+ it 'should tag a normal continuous variable' do
68
+ h = 'spec/files/measures/SetThermostatSchedules/measure.json'
69
+ measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
70
+ 'my_instance',
71
+ 'my instance display name',
72
+ h,
73
+ JSON.parse(File.read(h), symbolize_names: true))
74
+
75
+ expect(measure.name).to eq 'my_instance'
76
+ v = {
77
+ type: 'normal',
78
+ minimum: 0.5,
79
+ maximum: 20,
80
+ mean: 10,
81
+ standard_deviation: 2
82
+ }
83
+ r = measure.make_variable('cooling_sch', 'my variable', v)
84
+
85
+ h = measure.to_hash
86
+
87
+ expect(h[:variables].first.key?(:step_size)).to eq false
88
+
89
+ expect(r).to eq true
90
+ end
91
+
92
+ it 'should tag a uniform variable' do
93
+ h = 'spec/files/measures/SetThermostatSchedules/measure.json'
94
+ measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
95
+ 'my_instance',
96
+ 'my instance display name',
97
+ h,
98
+ JSON.parse(File.read(h), symbolize_names: true))
99
+
100
+ expect(measure.name).to eq 'my_instance'
101
+ v = {
102
+ type: 'uniform',
103
+ minimum: 0.5,
104
+ maximum: 20,
105
+ mean: 10
106
+ }
107
+ r = measure.make_variable('cooling_sch', 'my variable', v)
108
+
109
+ h = measure.to_hash
110
+
111
+ # puts JSON.pretty_generate(h)
112
+ expect(h[:variables].first.key?(:step_size)).to eq false
113
+
114
+ expect(r).to eq true
115
+ end
116
+ end
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Analysis::Formulation" tests="7" time="0.03787" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:50-07:00">
3
+ <testcase name="OpenStudio::Analysis::Formulation should create an analysis" time="0.001045">
4
+ </testcase>
5
+ <testcase name="OpenStudio::Analysis::Formulation should have a workflow object" time="8.2e-05">
6
+ </testcase>
7
+ <testcase name="OpenStudio::Analysis::Formulation should load the workflow from a file" time="0.001">
8
+ </testcase>
9
+ <testcase name="OpenStudio::Analysis::Formulation should save a hash (version 1)" time="0.030748">
10
+ </testcase>
11
+ <testcase name="OpenStudio::Analysis::Formulation should create a save an empty analysis" time="0.000744">
12
+ </testcase>
13
+ <testcase name="OpenStudio::Analysis::Formulation should increment objective functions" time="0.000127">
14
+ </testcase>
15
+ <testcase name="OpenStudio::Analysis::Formulation should create a new formulation" time="0.003436">
16
+ </testcase>
17
+ <system-out>
18
+ Parsing file version 1
19
+ Parsing file version 1
20
+ loading config settings from /Users/nlong/.bcl/config.yml
21
+ loading config settings from /Users/nlong/.bcl/config.yml
22
+ </system-out>
23
+ <system-err>
24
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
25
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
26
+ Deprecation Warning. workflow_step_type is no longer persisted
27
+ </system-err>
28
+ </testsuite>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::ServerApi create a new object instance" tests="1" time="0.013695" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:15-07:00">
3
- <testcase name="OpenStudio::Analysis::ServerApi create a new object instance should set the default host to localhost" time="0.000172">
2
+ <testsuite name="OpenStudio::Analysis::ServerApi create a new object instance" tests="1" time="0.005303" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:50-07:00">
3
+ <testcase name="OpenStudio::Analysis::ServerApi create a new object instance should set the default host to localhost" time="0.000162">
4
4
  </testcase>
5
5
  </testsuite>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::ServerApi test not localhost" tests="1" time="0.00058" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:15-07:00">
3
- <testcase name="OpenStudio::Analysis::ServerApi test not localhost should have a not localhost URL" time="0.000393">
2
+ <testsuite name="OpenStudio::Analysis::ServerApi test not localhost" tests="1" time="0.000568" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:50-07:00">
3
+ <testcase name="OpenStudio::Analysis::ServerApi test not localhost should have a not localhost URL" time="0.000378">
4
4
  </testcase>
5
5
  </testsuite>
@@ -1,3 +1,3 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::ServerApi" tests="0" time="9.3e-05" skipped="0" timestamp="2014-11-08T02:22:15-07:00">
2
+ <testsuite name="OpenStudio::Analysis::ServerApi" tests="0" time="0.000117" skipped="0" timestamp="2015-01-06T07:36:50-07:00">
3
3
  </testsuite>
@@ -1,13 +1,39 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::Translator::Excel discrete variables" tests="2" time="0.449326" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:06-07:00">
3
- <testcase name="OpenStudio::Analysis::Translator::Excel discrete variables should have parsed the spreadsheet" time="0.00139">
2
+ <testsuite name="OpenStudio::Analysis::Translator::Excel discrete variables" tests="2" time="0.471354" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:41-07:00">
3
+ <testcase name="OpenStudio::Analysis::Translator::Excel discrete variables should have parsed the spreadsheet" time="0.003573">
4
4
  </testcase>
5
- <testcase name="OpenStudio::Analysis::Translator::Excel discrete variables should save the file" time="0.016848">
5
+ <testcase name="OpenStudio::Analysis::Translator::Excel discrete variables should save the file" time="0.033966">
6
6
  </testcase>
7
7
  <system-out>
8
- {"variable_type"=&gt;"variable", "display_name"=&gt;"Alter Design Day Thermostats?", "display_name_short"=&gt;"Alter Design Day Thermostats?", "name"=&gt;"alter_design_days", "index"=&gt;3, "type"=&gt;"bool", "units"=&gt;nil, "distribution"=&gt;{"enumerations"=&gt;["true", "false"], "min"=&gt;"true", "max"=&gt;"true", "mean"=&gt;"false", "stddev"=&gt;"false", "discrete_values"=&gt;"['true','false']", "discrete_weights"=&gt;"[0.8,0.2]", "type"=&gt;"discrete_uncertain", "static_value"=&gt;"FALSE", "source"=&gt;nil}, "notes"=&gt;nil, "relation_to_eui"=&gt;nil}
8
+ {"variable_type"=&gt;"variable", "display_name"=&gt;"Alter Design Day Thermostats?", "display_name_short"=&gt;"Alter Design Day Thermostats?", "name"=&gt;"alter_design_days", "index"=&gt;3, "type"=&gt;"bool", "units"=&gt;nil, "distribution"=&gt;{"enumerations"=&gt;["true", "false"], "min"=&gt;true, "max"=&gt;true, "mean"=&gt;false, "stddev"=&gt;false, "discrete_values"=&gt;[true, false], "discrete_weights"=&gt;[0.8, 0.2], "type"=&gt;"discrete_uncertain", "static_value"=&gt;false, "delta_x"=&gt;nil, "source"=&gt;nil}, "notes"=&gt;nil, "relation_to_eui"=&gt;nil}
9
9
  Creating JSON and ZIP file for Example Analysis:0_1_11_discrete_variables
10
10
  Adding measure /Users/nlong/working/OpenStudio-analysis-gem/spec/files/measures/reduce_lighting_loads_by_percentage to zip file
11
11
  Adding measure /Users/nlong/working/OpenStudio-analysis-gem/spec/files/measures/example_measure_auto_directory_name to zip file
12
12
  </system-out>
13
+ <system-err>
14
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: discrete_uncertain
15
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
16
+ Deprecation Warning. workflow_step_type is no longer persisted
17
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
18
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
19
+ Deprecation Warning. workflow_step_type is no longer persisted
20
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
21
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
22
+ Deprecation Warning. workflow_step_type is no longer persisted
23
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
24
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
25
+ Deprecation Warning. workflow_step_type is no longer persisted
26
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: discrete_uncertain
27
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
28
+ Deprecation Warning. workflow_step_type is no longer persisted
29
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
30
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
31
+ Deprecation Warning. workflow_step_type is no longer persisted
32
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
33
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
34
+ Deprecation Warning. workflow_step_type is no longer persisted
35
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: discrete_uncertain
36
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
37
+ Deprecation Warning. workflow_step_type is no longer persisted
38
+ </system-err>
13
39
  </testsuite>
@@ -1,11 +1,19 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::Translator::Excel discrete with dynamic columns" tests="2" time="0.368755" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:07-07:00">
3
- <testcase name="OpenStudio::Analysis::Translator::Excel discrete with dynamic columns should have parsed the spreadsheet" time="0.000148">
2
+ <testsuite name="OpenStudio::Analysis::Translator::Excel discrete with dynamic columns" tests="2" time="0.393895" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:42-07:00">
3
+ <testcase name="OpenStudio::Analysis::Translator::Excel discrete with dynamic columns should have parsed the spreadsheet" time="0.000159">
4
4
  </testcase>
5
- <testcase name="OpenStudio::Analysis::Translator::Excel discrete with dynamic columns should save the file" time="0.012181">
5
+ <testcase name="OpenStudio::Analysis::Translator::Excel discrete with dynamic columns should save the file" time="0.030632">
6
6
  </testcase>
7
7
  <system-out>
8
8
  Creating JSON and ZIP file for test_model:0_1_12_discrete_dynamic_columns
9
9
  Adding measure /Users/nlong/working/OpenStudio-analysis-gem/spec/files/measures/example_measure_auto_directory_name to zip file
10
10
  </system-out>
11
+ <system-err>
12
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: discrete_uncertain
13
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
14
+ Deprecation Warning. workflow_step_type is no longer persisted
15
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: discrete_uncertain
16
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
17
+ Deprecation Warning. workflow_step_type is no longer persisted
18
+ </system-err>
11
19
  </testsuite>
@@ -1,14 +1,14 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::Translator::Excel no variables defined" tests="4" time="0.769701" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:03-07:00">
3
- <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should have excel data" time="0.190981">
2
+ <testsuite name="OpenStudio::Analysis::Translator::Excel no variables defined" tests="4" time="0.790654" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:37-07:00">
3
+ <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should have excel data" time="0.161278">
4
4
  </testcase>
5
- <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should process the excel file" time="0.252256">
5
+ <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should process the excel file" time="0.275632">
6
6
  </testcase>
7
- <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should not work because no variables defined" time="0.063078">
7
+ <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should not work because no variables defined" time="0.074529">
8
8
  </testcase>
9
- <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should not export to a JSON" time="0.262673">
9
+ <testcase name="OpenStudio::Analysis::Translator::Excel no variables defined should not export to a JSON" time="0.278602">
10
10
  </testcase>
11
11
  <system-out>
12
- #&lt;OpenStudio::Analysis::Translator::Excel:0x007fcc0c30c7f0&gt;
12
+ #&lt;OpenStudio::Analysis::Translator::Excel:0x007f955b1390a0&gt;
13
13
  </system-out>
14
14
  </testsuite>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::Translator::Excel proxy setup with user" tests="1" time="0.376302" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:06-07:00">
3
- <testcase name="OpenStudio::Analysis::Translator::Excel proxy setup with user should have a user" time="0.000248">
2
+ <testsuite name="OpenStudio::Analysis::Translator::Excel proxy setup with user" tests="1" time="0.395469" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:41-07:00">
3
+ <testcase name="OpenStudio::Analysis::Translator::Excel proxy setup with user should have a user" time="0.000184">
4
4
  </testcase>
5
5
  </testsuite>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::Translator::Excel proxy setup" tests="1" time="0.370704" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:05-07:00">
3
- <testcase name="OpenStudio::Analysis::Translator::Excel proxy setup should have a proxy setting" time="0.000268">
2
+ <testsuite name="OpenStudio::Analysis::Translator::Excel proxy setup" tests="1" time="0.412036" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:40-07:00">
3
+ <testcase name="OpenStudio::Analysis::Translator::Excel proxy setup should have a proxy setting" time="0.000206">
4
4
  </testcase>
5
5
  </testsuite>
@@ -1,18 +1,18 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="OpenStudio::Analysis::Translator::Excel setup output variables" tests="7" time="0.419312" failures="0" errors="0" skipped="0" timestamp="2014-11-08T02:22:07-07:00">
3
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have a model" time="0.000186">
2
+ <testsuite name="OpenStudio::Analysis::Translator::Excel setup output variables" tests="7" time="0.444562" failures="0" errors="0" skipped="0" timestamp="2015-01-06T07:36:42-07:00">
3
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have a model" time="0.000184">
4
4
  </testcase>
5
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have a weather file" time="7.1e-05">
5
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have a weather file" time="9.0e-05">
6
6
  </testcase>
7
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have notes and source" time="6.7e-05">
7
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have notes and source" time="8.1e-05">
8
8
  </testcase>
9
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have typed booleans" time="5.7e-05">
9
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have typed booleans" time="7.1e-05">
10
10
  </testcase>
11
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have algorithm setup" time="7.5e-05">
11
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should have algorithm setup" time="7.9e-05">
12
12
  </testcase>
13
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should create a valid hash" time="0.020303">
13
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should create a valid hash" time="0.006886">
14
14
  </testcase>
15
- <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should write a json" time="0.017488">
15
+ <testcase name="OpenStudio::Analysis::Translator::Excel setup output variables should write a json" time="0.034908">
16
16
  </testcase>
17
17
  <system-out>
18
18
  /Users/nlong/working/OpenStudio-analysis-gem/spec/files/partial_weather.epw
@@ -20,4 +20,48 @@ Creating JSON and ZIP file for Output Vars:0_1_09_outputvars
20
20
  Adding measure /Users/nlong/working/OpenStudio-analysis-gem/spec/files/measures/reduce_lighting_loads_by_percentage to zip file
21
21
  Adding measure /Users/nlong/working/OpenStudio-analysis-gem/spec/files/measures/example_measure_auto_directory_name to zip file
22
22
  </system-out>
23
+ <system-err>
24
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
25
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
26
+ Deprecation Warning. workflow_step_type is no longer persisted
27
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
28
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
29
+ Deprecation Warning. workflow_step_type is no longer persisted
30
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
31
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
32
+ Deprecation Warning. workflow_step_type is no longer persisted
33
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
34
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
35
+ Deprecation Warning. workflow_step_type is no longer persisted
36
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
37
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
38
+ Deprecation Warning. workflow_step_type is no longer persisted
39
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
40
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
41
+ Deprecation Warning. workflow_step_type is no longer persisted
42
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
43
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
44
+ Deprecation Warning. workflow_step_type is no longer persisted
45
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
46
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
47
+ Deprecation Warning. workflow_step_type is no longer persisted
48
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
49
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
50
+ Deprecation Warning. workflow_step_type is no longer persisted
51
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
52
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
53
+ Deprecation Warning. workflow_step_type is no longer persisted
54
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: uniform_uncertain
55
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
56
+ Deprecation Warning. workflow_step_type is no longer persisted
57
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
58
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
59
+ Deprecation Warning. workflow_step_type is no longer persisted
60
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
61
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
62
+ Deprecation Warning. workflow_step_type is no longer persisted
63
+ Deprecation Warning. In Version 0.5 the _uncertain text will be removed from distribution types: triangle_uncertain
64
+ Deprecation Warning. RubyContinuousVariable (OpenStudio called this the variable_type) is no longer persisted
65
+ Deprecation Warning. workflow_step_type is no longer persisted
66
+ </system-err>
23
67
  </testsuite>