openstudio-recommendation-engine 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ ######################################################################
2
+ # Copyright (c) 2008-2013, Alliance for Sustainable Energy.
3
+ # All rights reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ #####################################################################
19
+
20
+ #load a model into OS & version translates, exiting and erroring if a problem is found
21
+ module OpenStudio
22
+ def safe_load_model(model_path_string)
23
+ model_path = OpenStudio::Path.new(model_path_string)
24
+ if OpenStudio::exists(model_path)
25
+ versionTranslator = OpenStudio::OSVersion::VersionTranslator.new
26
+ model = versionTranslator.loadModel(model_path)
27
+ if model.empty?
28
+ puts "Version translation failed for #{model_path_string}"
29
+ exit
30
+ else
31
+ model = model.get
32
+ end
33
+ else
34
+ raise "#{model_path_string} couldn't be found"
35
+ end
36
+ return model
37
+ end
38
+ module_function :safe_load_model
39
+ end
@@ -0,0 +1,143 @@
1
+ ######################################################################
2
+ # Copyright (c) 2008-2013, Alliance for Sustainable Energy.
3
+ # All rights reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ #####################################################################
19
+
20
+ module OpenStudio
21
+ module RecommendationEngine
22
+ class RecommendationEngine
23
+ def initialize(model, path_to_measures)
24
+ @model = model
25
+ @path_to_measures = path_to_measures
26
+
27
+ init
28
+ end
29
+
30
+ def init
31
+ measure_checks = Dir.glob("#{@path_to_measures}/**/recommendation.rb")
32
+
33
+ puts "List of measures: #{measure_checks.inspect}"
34
+ results = []
35
+ measure_checks.each do |measure|
36
+ require "#{File.expand_path(measure)}"
37
+
38
+ measure_class_name = File.basename(File.expand_path("../..",measure))
39
+ puts "measure class name is: #{measure_class_name}"
40
+
41
+ m = measure_class_name.constantize.new
42
+ puts m.inspect
43
+
44
+ # recommendation engine ?
45
+ #require "#{a.name}::MeasureApplciblitychere.new()."
46
+
47
+ if @model
48
+ measure_check = Measure::MeasureApplicabilityChecker.new(@model)
49
+ measure_check.check_applicability
50
+ else
51
+ raise "No model passed into the recommendation engine"
52
+ end
53
+
54
+
55
+ results << measure_check.result
56
+ end
57
+
58
+ return results
59
+
60
+ end
61
+
62
+ end
63
+ end
64
+
65
+
66
+ end
67
+
68
+ # Microsoft Windows [Version 6.1.7601]
69
+ # Copyright (c) 2009 Microsoft Corporation. All rights reserved.
70
+
71
+ # C:\Users\aparker>irb
72
+ # irb(main):001:0> require
73
+ # ArgumentError: wrong number of arguments (0 for 1)
74
+ # from (irb):1:in `require'
75
+ # from (irb):1
76
+ # irb(main):002:0> ^C
77
+ # irb(main):002:0> exit
78
+ # Terminate batch job (Y/N)? n
79
+
80
+ # C:\Users\aparker>gem install parallel
81
+ # Fetching: parallel-0.9.2.gem (100%)
82
+ # Successfully installed parallel-0.9.2
83
+ # 1 gem installed
84
+ # Installing ri documentation for parallel-0.9.2...
85
+ # Installing RDoc documentation for parallel-0.9.2...
86
+
87
+ # C:\Users\aparker>irb
88
+ # irb(main):001:0> Parallel.each(['a','b','c']){|a| puts a}
89
+ # NameError: uninitialized constant Parallel
90
+ # from (irb):1
91
+ # irb(main):002:0> require 'parallel'
92
+ # LoadError: no such file to load -- parallel
93
+ # from (irb):2:in `require'
94
+ # from (irb):2
95
+ # irb(main):003:0> require 'rubygems'
96
+ # => true
97
+ # irb(main):004:0> require 'parallel'
98
+ # => true
99
+ # irb(main):005:0> Parallel.each(['a','b','c']){|a| puts a}
100
+ # NotImplementedError: fork() function is unimplemented on this machine
101
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:291:in `fork'
102
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:291:in `worker'
103
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:279:in `create_workers'
104
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:278:in `each'
105
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:278:in `create_workers'
106
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:242:in `work_in_processes'
107
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:114:in `map'
108
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:81:in `each'
109
+ # from (irb):5
110
+ # irb(main):006:0> Parallel.each(['a','b','c'], :in_threads => 3){|a| puts a}
111
+ # abc
112
+
113
+
114
+ # => ["a", "b", "c"]
115
+ # irb(main):007:0> Parallel.each(['a','b','c'], :in_threads => 1){|a| puts a}
116
+ # a
117
+ # b
118
+ # c
119
+ # => ["a", "b", "c"]
120
+ # irb(main):008:0> Parallel.each(['a','b','c'], :in_threads => 2){|a| puts wait 10}
121
+ # NoMethodError: undefined method `wait' for main:Object
122
+ # from (irb):8
123
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:386:in `call'
124
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:386:in `call_with_index'
125
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:229:in `work_in_threads'
126
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:397:in `with_instrumentation'
127
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:227:in `work_in_threads'
128
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:221:in `loop'
129
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:221:in `work_in_threads'
130
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:65:in `in_threads'
131
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:64:in `initialize'
132
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:64:in `new'
133
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:64:in `in_threads'
134
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:63:in `times'
135
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:63:in `in_threads'
136
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:219:in `work_in_threads'
137
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:112:in `map'
138
+ # from C:/Ruby187/lib/ruby/gems/1.8/gems/parallel-0.9.2/lib/parallel.rb:81:in `each'
139
+ # from (irb):8
140
+ # from ♥:0irb(main):009:0> Parallel.each(['a','b','c'], :in_threads => 2){|Terminate batch job (Y/N)?
141
+ # ^C
142
+ # C:\Users\aparker>irb
143
+ # irb(main):001:0>
@@ -0,0 +1,24 @@
1
+ ######################################################################
2
+ # Copyright (c) 2008-2013, Alliance for Sustainable Energy.
3
+ # All rights reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ ######################################################################
19
+
20
+ module OpenStudio
21
+ module RecommendationEngine
22
+ VERSION = "0.1.0"
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ require 'rubygems' # for 1.8.7
2
+
3
+ begin
4
+ require 'openstudio'
5
+ $openstudio_loaded = true
6
+ rescue
7
+ $openstudio_loaded = false
8
+ end
9
+
10
+ require 'active_support/core_ext/string' # for constantize
11
+ require 'parallel'
12
+ require 'openstudio/recommendation_engine/recommendation_engine'
13
+ require 'openstudio/recommendation_engine/version'
14
+ require 'openstudio/helpers/safe_load'
15
+
16
+
17
+
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openstudio-recommendation-engine
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Nicholas Long
14
+ - Andrew Parker
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2014-03-06 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: parallel
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ prerelease: false
33
+ type: :runtime
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: active_support
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ prerelease: false
47
+ type: :runtime
48
+ requirement: *id002
49
+ description: This gem contains the framework needed to execute the recommendation engine on measures that have defined their recommendations.
50
+ email: Nicholas.Long@nrel.gov
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - lib/openstudio/helpers/safe_load.rb
59
+ - lib/openstudio/recommendation_engine/recommendation_engine.rb
60
+ - lib/openstudio/recommendation_engine/version.rb
61
+ - lib/recommendation_engine.rb
62
+ homepage: http://openstudio.nrel.gov
63
+ licenses:
64
+ - LGPL
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 57
76
+ segments:
77
+ - 1
78
+ - 8
79
+ - 7
80
+ version: 1.8.7
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.24
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: OpenStudio Recommendation EngineL
97
+ test_files: []
98
+