flukso4r 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of flukso4r might be problematic. Click here for more details.

data/Rakefile CHANGED
@@ -17,9 +17,10 @@ begin
17
17
  gem.files = FileList["[A-Z]*", "{lib,etc,test}/**/*"]
18
18
 
19
19
  #gem.add_dependency('oauth', '~> 0.3.6')
20
- gem.add_dependency('httparty', '~> 0.4.3')
21
- gem.add_dependency('sqlite3-ruby', '~> 1.2.5')
22
- #gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
20
+ gem.add_dependency('httparty')
21
+ gem.add_dependency('crack')
22
+ gem.add_dependency('sqlite3-ruby')
23
+ gem.add_development_dependency("shoulda")
23
24
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
24
25
  end
25
26
  Jeweler::GemcutterTasks.new
@@ -27,28 +28,29 @@ rescue LoadError
27
28
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28
29
  end
29
30
 
30
- require 'rake/testtask'
31
- Rake::TestTask.new(:test) do |test|
32
- test.libs << 'lib' << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
-
37
- begin
38
- require 'rcov/rcovtask'
39
- Rcov::RcovTask.new do |test|
40
- test.libs << 'test'
41
- test.pattern = 'test/**/test_*.rb'
42
- test.verbose = true
43
- end
44
- rescue LoadError
45
- task :rcov do
46
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
47
- end
48
- end
31
+ #require 'rake/testtask'
32
+ #Rake::TestTask.new(:test) do |test|
33
+ # test.libs << 'lib' << 'test'
34
+ # test.pattern = 'test/**/test_*.rb'
35
+ # test.verbose = true
36
+ #end
37
+ #
38
+ #begin
39
+ # require 'rcov/rcovtask'
40
+ # Rcov::RcovTask.new do |test|
41
+ # test.libs << 'test'
42
+ # test.pattern = 'test/**/test_*.rb'
43
+ # test.verbose = true
44
+ # end
45
+ #rescue LoadError
46
+ # task :rcov do
47
+ # abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
48
+ # end
49
+ #end
50
+ #
51
+ #task :test => :check_dependencies
49
52
 
50
- task :test => :check_dependencies
51
- task :default => :test
53
+ task :default => :check_dependencies
52
54
 
53
55
  require 'rake/rdoctask'
54
56
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.6
1
+ 0.3.7
data/bin/flukso_create_db CHANGED
File without changes
data/bin/flukso_export_db CHANGED
File without changes
data/etc/flukso4rrc CHANGED
@@ -2,5 +2,5 @@ DB_FILE: "/tmp/demo_database.sqlite3"
2
2
  DB_TABLE_NAME: "UTCReadings"
3
3
  ACCESS_TOKEN: "3f..."
4
4
  SENSOR_ID: "0e...."
5
- BASE_URL: "https://api.flukso.net/sensor"
5
+ BASE_URL: "https://api.mysmartgrid.de:8443/sensor"
6
6
 
data/lib/flukso.rb CHANGED
@@ -23,8 +23,9 @@
23
23
  require 'forwardable'
24
24
  require 'rubygems'
25
25
 
26
- gem 'httparty', '~> 0.4.3'
26
+ gem 'httparty'
27
27
  require 'httparty'
28
+ require 'crack'
28
29
 
29
30
  module Flukso
30
31
  class FluksoError < StandardError
@@ -56,3 +57,5 @@ require File.join(directory, 'flukso', 'request')
56
57
  require File.join(directory, 'flukso', 'api')
57
58
  require File.join(directory, 'flukso', 'database')
58
59
  require File.join(directory, 'flukso', 'export')
60
+ require File.join(directory, 'flukso', 'R')
61
+ require File.join(directory, 'flukso', 'plots')
data/lib/flukso/R.rb ADDED
@@ -0,0 +1,93 @@
1
+ # This file is part of Flukso4R
2
+ # (c) 2010 Mathias Dalheimer, md@gonium.net
3
+ #
4
+ # Flukso4R is free software; you can
5
+ # redistribute it and/or modify it under the terms of the GNU General Public
6
+ # License as published by the Free Software Foundation; either version 2 of
7
+ # the License, or any later version.
8
+ #
9
+ # CGWG is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with CGWG; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require "tempfile"
19
+ directory = File.expand_path(File.dirname(__FILE__))
20
+ require File.join(directory, 'plots')
21
+ #require "ruby-debug"
22
+
23
+ module Flukso
24
+ # Run R without saving of environment, as quiet as possible.
25
+ R_CMD = "Rscript --vanilla"
26
+
27
+ class RRunner
28
+ def initialize(workingdir)
29
+ # TODO: Check whether R command is available.
30
+ @workingdir = workingdir
31
+ puts "Using working directory #{@workingdir}" if $verbose
32
+ end
33
+
34
+ # returns a preamble string: which file to use etc.
35
+ def createPreamble(outfilename)
36
+ absOutFilename = File.expand_path(File.join(@workingdir, outfilename))
37
+ cmd= <<-END_OF_CMD
38
+ pdf("#{absOutFilename}");
39
+ END_OF_CMD
40
+ puts "using filename #{absOutFilename} for output." if $verbose
41
+ return cmd
42
+ end
43
+
44
+ # returns a closing string - close file, terminate R
45
+ def createClosing()
46
+ close=<<-END_OF_CMD
47
+ q()
48
+ END_OF_CMD
49
+ return close
50
+ end
51
+
52
+ # Executes the given command. Expects a string that contains the
53
+ # commands to execute.
54
+ def executeCommandString(outfilename, commands)
55
+ cmdSet = createPreamble(outfilename)
56
+ cmdSet << commands << createClosing
57
+ # The Tempfile will get deleted automagically when ruby terminates.
58
+ cmdfile=Tempfile.new("r-cmd", @workingdir)
59
+ cmdfile.print(cmdSet)
60
+ cmdfile.close()
61
+ puts "executing commands:\n#{cmdSet}" if $verbose
62
+ commandline="#{R_CMD} #{cmdfile.path}"
63
+ puts "using commandline: #{commandline}" if $verbose
64
+ stdout = %x[#{commandline}]
65
+ puts "R (Exitcode: #{$?}) said: #{stdout}" if $verbose
66
+ end
67
+
68
+ def execute(outfilename, commands)
69
+ puts commands.class
70
+ if commands.class != Array
71
+ raise "Please provide an array of commands to the execute call."
72
+ end
73
+ cmdString=""
74
+ commands.each{|command|
75
+ cmdString << command.cmd();
76
+ cmdString << "# command separator\n"
77
+ }
78
+ executeCommandString(outfilename, cmdString);
79
+ end
80
+
81
+ end
82
+ end
83
+
84
+
85
+ # Test routines below - execute this file directly...
86
+ if __FILE__ == $0
87
+ $verbose=true;
88
+ runner=Flukso::RRunner.new(".");
89
+ plotCmd=Flukso::TestPlot.new();
90
+ plots=Array.new();
91
+ plots << plotCmd;
92
+ runner.execute("foo.pdf", plots);
93
+ end
@@ -187,6 +187,6 @@ SQL
187
187
  end
188
188
  end
189
189
 
190
- class ElementNotFoundError < RuntimeError
191
- end
192
- end
190
+ class ElementNotFoundError < RuntimeError
191
+ end
192
+ end
@@ -0,0 +1,490 @@
1
+ # This file is part of Flukso4R
2
+ # (c) 2010 Mathias Dalheimer, md@gonium.net
3
+ #
4
+ # Flukso4R is free software; you can
5
+ # redistribute it and/or modify it under the terms of the GNU General Public
6
+ # License as published by the Free Software Foundation; either version 2 of
7
+ # the License, or any later version.
8
+ #
9
+ # CGWG is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with CGWG; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ def generateRandomString()
18
+ chars = ("a".."z").to_a + ("1".."9").to_a
19
+ return Array.new(16, '').collect{chars[rand(chars.size)]}.join
20
+ end
21
+
22
+ module Flukso
23
+ # a simple scatterplot
24
+ class ScatterPlotDaily
25
+ def initialize(annotation)
26
+ @annotation=annotation;
27
+ @readings=Array.new()
28
+ @dataset_id="data"+generateRandomString();
29
+ end
30
+ def addReading(reading);
31
+ @readings << reading
32
+ end
33
+ def create_dataframe_cmd()
34
+ cmd_create_dataframe= <<-END_OF_CMD
35
+ #{@dataset_id} <- data.frame(
36
+ date=character(),
37
+ dayofweek=character(),
38
+ period=numeric(),
39
+ value=numeric()
40
+ );
41
+ END_OF_CMD
42
+ @readings.each{|reading|
43
+ # calculate some values.
44
+ currenttime=Time.at(reading.utc_timestamp);
45
+ cmd_compose_data= <<-END_OF_CMD
46
+ newline<-data.frame(#{reading.utc_timestamp}, "#{reading.dayOfWeek}", #{reading.period}, #{reading.value});
47
+ colnames(newline)<- colnames(#{@dataset_id});
48
+ #{@dataset_id} <- rbind(#{@dataset_id}, newline);
49
+ END_OF_CMD
50
+ cmd_create_dataframe << cmd_compose_data;
51
+ }
52
+ return cmd_create_dataframe
53
+ end
54
+ def cmd()
55
+ dataframe=create_dataframe_cmd();
56
+ cmd= <<-END_OF_CMD
57
+ # plot commmands.
58
+ library(lattice);
59
+ y_max=max(#{@dataset_id}$value);
60
+ title<-paste("Daily Power Consumption", "#{@annotation}");
61
+ data_points<-paste("Number of data points:",nrow(#{@dataset_id}));
62
+ cat("Plotting scatterplot:", title, data_points, "\n");
63
+ xyplot(#{@dataset_id}$value ~ #{@dataset_id}$period, main=title,
64
+ ylab="Power Usage [W]", xlab="Time Period [15min Intervals]",
65
+ sub=data_points, ylim=c(0,y_max), xlim=c(0,95));
66
+ END_OF_CMD
67
+ return dataframe << cmd
68
+ end
69
+ end
70
+
71
+ # Plot a single day as a line.
72
+ class DailyLine
73
+ def initialize(annotation, day, month, year)
74
+ @annotation=annotation;
75
+ @day=day
76
+ @month=month
77
+ @year=year
78
+ @readings=Array.new()
79
+ @dataset_id="data"+generateRandomString();
80
+ end
81
+ def addReading(reading);
82
+ # Check wether the reading is on our day.
83
+ if reading.isOnDay?(@day, @month, @year)
84
+ @readings << reading
85
+ # puts "adding reading." if $verbose
86
+ #else
87
+ # puts "skipping reading (not on desired day)" if $verbose
88
+ end
89
+ end
90
+ def create_dataframe_cmd()
91
+ cmd_create_dataframe= <<-END_OF_CMD
92
+ #{@dataset_id} <- data.frame(
93
+ date=character(),
94
+ dayofweek=character(),
95
+ period=numeric(),
96
+ value=numeric()
97
+ );
98
+ END_OF_CMD
99
+ @readings.each{|reading|
100
+ # calculate some values.
101
+ currenttime=Time.at(reading.utc_timestamp);
102
+ cmd_compose_data= <<-END_OF_CMD
103
+ newline<-data.frame(#{reading.utc_timestamp}, "#{reading.dayOfWeek}", #{reading.period}, #{reading.value});
104
+ colnames(newline)<- colnames(#{@dataset_id});
105
+ #{@dataset_id} <- rbind(#{@dataset_id}, newline);
106
+ END_OF_CMD
107
+ cmd_create_dataframe << cmd_compose_data;
108
+ }
109
+ return cmd_create_dataframe
110
+ end
111
+ def cmd()
112
+ if @readings.empty?
113
+ raise "no values selected - cannot create DailyLine plot for #{@year}-#{@month}-#{@day}"
114
+ end
115
+ dataframe=create_dataframe_cmd();
116
+ cmd= <<-END_OF_CMD
117
+ # plot commmands.
118
+ library(lattice);
119
+ y_max=max(#{@dataset_id}$value);
120
+ title<-paste("Daily Power Consumption", "#{@annotation}")
121
+ data_points<-paste("Number of data points:",nrow(#{@dataset_id}));
122
+ plot(#{@dataset_id}$value ~ #{@dataset_id}$period, main=title, type="l",
123
+ ylab="Power Usage [W]", xlab="Time Period [15min Intervals]",
124
+ sub=data_points, ylim=c(0,y_max), xlim=c(0,95));
125
+ END_OF_CMD
126
+ return dataframe << cmd
127
+ end
128
+
129
+ end
130
+
131
+ # Simple test plot that plots 100 points.
132
+ class TestPlot
133
+ def cmd()
134
+ cmd= <<-END_OF_CMD
135
+ v=1:100
136
+ p=1:100
137
+ plot(v,p)
138
+ END_OF_CMD
139
+ return cmd
140
+ end
141
+ end
142
+
143
+ end
144
+
145
+ # The following classes provide some ideas. Not used.
146
+ class RExperimentAnalysis
147
+ def initialize(path, datafile, loadlevel)
148
+ @workingdir=path
149
+ @datafile = File.expand_path(File.join(path, datafile))
150
+ @loadlevel = loadlevel
151
+ puts "Using data from file #{@datafile}" if $verbose
152
+ @runner = RRunner.new(path)
153
+ end
154
+
155
+ def plotSingleRun_Queuetimes
156
+ drawcmd=<<-END_OF_CMD
157
+ plot(data$stime, data$qtime,
158
+ main="Queuetime for all jobs",
159
+ xlab="submittime",
160
+ ylab="queuetime"
161
+ )
162
+ END_OF_CMD
163
+ outfile="queuetimes-"+@loadlevel.to_s
164
+ @runner.execute(@datafile, outfile, drawcmd)
165
+ end
166
+
167
+ def plotSingleRun_Price
168
+ drawcmd=<<-END_OF_CMD
169
+ plot(data$price,
170
+ main="Price for all jobs",
171
+ xlab="Job ID",
172
+ ylab="price"
173
+ )
174
+ END_OF_CMD
175
+ outfile="price-"+@loadlevel.to_s
176
+ @runner.execute(@datafile, outfile, drawcmd)
177
+ end
178
+
179
+ def plotSingleRun_PricePrefVsPrice()
180
+ drawcmd=<<-END_OF_CMD
181
+ plot(data$pricepref, data$pricert,
182
+ main="Price preference vs. price per second",
183
+ xlab="Price Preference",
184
+ ylab="price/runtime [price/s]"
185
+ )
186
+ END_OF_CMD
187
+ outfile="priceprefvspricert-"+@loadlevel.to_s
188
+ @runner.execute(@datafile, outfile, drawcmd)
189
+ end
190
+
191
+ def plotSingleRun_PerfPrefVsQueueTime()
192
+ drawcmd=<<-END_OF_CMD
193
+ plot(data$perfpref, data$qtime,
194
+ main="Performance preference vs. queuetime",
195
+ xlab="Performance Preference",
196
+ ylab="absolute queuetime [s]"
197
+ )
198
+ END_OF_CMD
199
+ outfile="perfprefvsqtime-"+@loadlevel.to_s
200
+ @runner.execute(@datafile, outfile, drawcmd)
201
+ end
202
+
203
+ def plotSingleRun_PricePerSecond
204
+ drawcmd=<<-END_OF_CMD
205
+ plot(data$pricert,
206
+ main="Price per second for all jobs",
207
+ xlab="Job ID",
208
+ ylab="price/runtime [price/s]"
209
+ )
210
+ END_OF_CMD
211
+ outfile="pricepersecond-"+@loadlevel.to_s
212
+ @runner.execute(@datafile, outfile, drawcmd)
213
+ end
214
+
215
+ def plotSingleRun_PriceHistogram
216
+ drawcmd=<<-END_OF_CMD
217
+ hist(data$pricert,
218
+ main="Histogram of prices per second",
219
+ xlab="Price per second",
220
+ ylab="Frequency"
221
+ )
222
+ END_OF_CMD
223
+ outfile="histpricepersecond-"+@loadlevel.to_s
224
+ @runner.execute(@datafile, outfile, drawcmd)
225
+ end
226
+
227
+ def plotSingleRun_QueuetimeHistogram
228
+ drawcmd=<<-END_OF_CMD
229
+ hist(data$qtime,
230
+ main="Histogram of queuetimes",
231
+ xlab="Queuetime [s]",
232
+ ylab="Frequency"
233
+ )
234
+ END_OF_CMD
235
+ outfile="histqueuetimes-"+@loadlevel.to_s
236
+ @runner.execute(@datafile, outfile, drawcmd)
237
+ end
238
+
239
+ def plotSingleRun_perfPrefHistogram
240
+ drawcmd=<<-END_OF_CMD
241
+ hist(data$perfpref,
242
+ main="Histogram of user preferences",
243
+ xlab="Performance Preference",
244
+ ylab="Frequency"
245
+ )
246
+ END_OF_CMD
247
+ outfile="histperfpref-"+@loadlevel.to_s
248
+ @runner.execute(@datafile, outfile, drawcmd)
249
+ end
250
+
251
+ def plotSingleRun
252
+ methods.grep(/^plotSingleRun_/){|m|
253
+ self.send(m)
254
+ }
255
+ sleep(1)
256
+ end
257
+ end
258
+
259
+
260
+ class PAES_Analysis
261
+ def initialize(path, annotationsfile)
262
+ @workingdir=path
263
+ @annotationsfile=annotationsfile
264
+ if @annotationsfile != nil
265
+ @annotations=AnnotationCollection.new(@annotationsfile)
266
+ end
267
+ @runner = RRunner.new(path)
268
+ end
269
+ def plotSingleRun
270
+ methods.grep(/^plotSingleRun_/){|m|
271
+ self.send(m)
272
+ }
273
+ sleep(1)
274
+ end
275
+ def arrayToC(input)
276
+ retval="c("
277
+ input.each{|element|
278
+ if element.instance_of?(String)
279
+ retval += "\"#{element}\","
280
+ else
281
+ retval += "#{element},"
282
+ end
283
+ }
284
+ retval.sub!(/,$/, ""); # delete the last comma
285
+ return retval+")";
286
+ end
287
+ ###
288
+ ## takes a drawcommand as an argument and adds annotations
289
+ ## as needed.
290
+ ## TODO: Points are not plotted if they are out of the range of
291
+ ## the plot - this might be necessary in the future.
292
+ #
293
+ def appendAnnotations(drawcmd)
294
+ if @annotations != nil
295
+ puts "Adding annotations\n#{@annotations.to_s}"
296
+ colors=Array.new()
297
+ labels=Array.new()
298
+ ltyInfo=Array.new()
299
+ pchInfo=Array.new()
300
+ counter=0;
301
+ pointlines=""
302
+ @annotations.each{|a|
303
+ counter+=1;
304
+ colors << counter;
305
+ labels << a.text;
306
+ pointlines+="points(#{a.qt}, #{a.price}, type=\"p\", pty=2, col=#{counter})\n"
307
+ ltyInfo << -1;
308
+ pchInfo << 1;
309
+ }
310
+ cols=arrayToC(colors)
311
+ labelList=arrayToC(labels)
312
+ ltyList=arrayToC(ltyInfo)
313
+ pchList=arrayToC(pchInfo)
314
+ drawcmd+=<<-EOC
315
+ cols=#{cols}
316
+ labels=#{labelList}
317
+ #{pointlines}
318
+ legend("topright", labels, col = cols,
319
+ text.col = "black", lty = #{ltyList}, pch = #{pchList},
320
+ bg = 'gray90')
321
+ EOC
322
+ end
323
+ return drawcmd
324
+ end
325
+ def plotSingleRun_ParetoSchedules_Absolute
326
+ basename="absolute-results"
327
+ #main="Pareto Front (absolute values)",
328
+ drawcmd=<<-END_OF_CMD
329
+ plot(data$QT, data$Price, type="b",
330
+ xlab="queue time (s)",
331
+ ylab="price"
332
+ )
333
+ END_OF_CMD
334
+ infile=File.join(@workingdir, basename+".txt")
335
+ outfile=basename+".eps"
336
+ puts "infile: #{infile}"
337
+ puts "outfile: #{outfile}"
338
+ @runner.execute(infile, outfile, drawcmd)
339
+ end
340
+ def plotSingleRun_ParetoSchedules_Relative
341
+ basename="relative-results"
342
+ max_qt_annotation = @annotations.getMaxQT()
343
+ max_price_annotation = @annotations.getMaxPrice()
344
+ min_qt_annotation = @annotations.getMinQT()
345
+ min_price_annotation = @annotations.getMinPrice()
346
+ puts "### Calculated: #{max_qt_annotation}, #{max_price_annotation}"
347
+ #main="Pareto Front (relative values)",
348
+ drawcmd=<<-END_OF_CMD
349
+ max_qt<-max(data$QT, #{max_qt_annotation});
350
+ max_price<-max(data$Price, #{max_price_annotation});
351
+ min_qt<-min(data$QT, #{min_qt_annotation});
352
+ min_price<-min(data$Price, #{min_price_annotation});
353
+ qt_range<-c(min_qt,max_qt);
354
+ price_range<-c(min_price,max_price);
355
+ plot(qt_range, price_range, type="n",
356
+ xlab="queue time (s)",
357
+ ylab="price / second"
358
+ )
359
+ points(data$QT, data$Price, type="b")
360
+ END_OF_CMD
361
+ drawcmd=appendAnnotations(drawcmd)
362
+ infile=File.join(@workingdir, basename+".txt")
363
+ outfile=basename+".eps"
364
+ puts "infile: #{infile}"
365
+ puts "outfile: #{outfile}"
366
+ @runner.execute(infile, outfile, drawcmd)
367
+ end
368
+ def plotSingleRun_Runtime
369
+ basename="runtime-report"
370
+ drawcmd=<<-END_OF_CMD
371
+ l<-length(data$acc)
372
+ range<-1:l
373
+ plot(range, data$acc, type="n",
374
+ xlab="Iteration (x 1000)",
375
+ ylab="Dominant Solutions"
376
+ )
377
+ points(range, data$acc, type="l", lty=1)
378
+ END_OF_CMD
379
+ infile=File.join(@workingdir, basename+".txt")
380
+ outfile=basename+".eps"
381
+ puts "infile: #{infile}"
382
+ puts "outfile: #{outfile}"
383
+ @runner.execute(infile, outfile, drawcmd)
384
+ end
385
+ def plotSingleRun_Runtime_Distance
386
+ basename="runtime-report"
387
+ drawcmd=<<-END_OF_CMD
388
+ l<-length(data$distance)
389
+ range<-1:l
390
+ plot(range, data$distance, type="n",
391
+ xlab="Iteration (x 1000)",
392
+ ylab="Distance"
393
+ )
394
+ points(range, data$distance, type="l", lty=2)
395
+ END_OF_CMD
396
+ infile=File.join(@workingdir, basename+".txt")
397
+ outfile=basename+"-distance.eps"
398
+ puts "infile: #{infile}"
399
+ puts "outfile: #{outfile}"
400
+ @runner.execute(infile, outfile, drawcmd)
401
+ end
402
+
403
+ def plotSingleRun_ParetoSchedules_Intermediates
404
+ # Search for all intermediate-* files in the data directory
405
+ Dir.foreach(@workingdir) {|file|
406
+ #puts "checking #{file}"
407
+ if file =~ /^intermediate-/
408
+ if not file =~ /.eps$/
409
+ plotIntermediate(file)
410
+ end
411
+ end
412
+ }
413
+ end
414
+ def plotIntermediate(filename)
415
+ drawcmd=<<-END_OF_CMD
416
+ plot(data$QT, data$Price, type="b",
417
+ main="Pareto Front (absolute values)",
418
+ xlab="queue time (s)",
419
+ ylab="price"
420
+ )
421
+ END_OF_CMD
422
+ infile=File.join(@workingdir, filename)
423
+ outfile=filename+".eps"
424
+ puts "infile: #{infile}"
425
+ puts "outfile: #{outfile}"
426
+ @runner.execute(infile, outfile, drawcmd)
427
+ end
428
+
429
+ end
430
+
431
+
432
+
433
+ class SA_Analysis
434
+ def initialize(path, datafile, loadlevel)
435
+ @workingdir=path
436
+ @datafile = File.expand_path(File.join(path, datafile))
437
+ @loadlevel = loadlevel
438
+ puts "Using data from file #{@datafile}" if $verbose
439
+ @runner = RRunner.new(path)
440
+ end
441
+ def plotSingleRun
442
+ methods.grep(/^plotSingleRun_/){|m|
443
+ self.send(m)
444
+ }
445
+ sleep(1)
446
+ end
447
+ def plotSingleRun_Energy
448
+ drawcmd=<<-END_OF_CMD
449
+ l<-length(data$Energy)
450
+ range<-1:l
451
+ plot(range, data$Energy, type="n",
452
+ main="Energy of the Solutions",
453
+ xlab="Iteration",
454
+ ylab="Absolute Energy"
455
+ )
456
+ points(range, data$Energy)
457
+ END_OF_CMD
458
+ outfile="sa-energy-"+@loadlevel.to_s
459
+ @runner.execute(@datafile, outfile, drawcmd)
460
+ end
461
+ def plotSingleRun_Temperature
462
+ drawcmd=<<-END_OF_CMD
463
+ l<-length(data$Temperature)
464
+ range<-1:l
465
+ plot(range, data$Temperature, type="n",
466
+ main="Temperature of the Solutions",
467
+ xlab="Iteration",
468
+ ylab="Temperature"
469
+ )
470
+ points(range, data$Temperature, pch=1)
471
+ END_OF_CMD
472
+ outfile="sa-temperature-"+@loadlevel.to_s
473
+ @runner.execute(@datafile, outfile, drawcmd)
474
+ end
475
+ def plotSingleRun_Accepted
476
+ drawcmd=<<-END_OF_CMD
477
+ l<-length(data$Accepted)
478
+ range<-1:l
479
+ plot(range, data$Accepted, type="n",
480
+ main="Number of Accepted Solutions",
481
+ xlab="Iteration",
482
+ ylab="# Accepted"
483
+ )
484
+ points(range, data$Accepted, pch=1)
485
+ END_OF_CMD
486
+ outfile="sa-accepted-"+@loadlevel.to_s
487
+ @runner.execute(@datafile, outfile, drawcmd)
488
+ end
489
+ end
490
+
@@ -41,6 +41,28 @@ module Flukso
41
41
  def to_s
42
42
  return "#{@utc_timestamp} -> #{@value}"
43
43
  end
44
+ def time
45
+ return Time.at(@utc_timestamp);
46
+ end
47
+ def dayOfWeek
48
+ currenttime=Time.at(@utc_timestamp);
49
+ return currenttime.strftime("%a");
50
+ end
51
+ def isOnDay?(day,month,year)
52
+ starttime=Time.mktime(year, month, day, 0, 0);
53
+ endtime=Time.mktime(year, month, day, 23, 59);
54
+ event=Time.at(@utc_timestamp);
55
+ if ((starttime <= event) and (event <= endtime))
56
+ return true
57
+ else
58
+ return false
59
+ end
60
+ end
61
+ def period
62
+ currenttime=Time.at(@utc_timestamp);
63
+ period=(currenttime.hour * 4) + (currenttime.min / 15);
64
+ return period
65
+ end
44
66
  end
45
67
 
46
68
  end
metadata CHANGED
@@ -1,92 +1,133 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: flukso4r
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.7
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 7
9
+ prerelease: false
5
10
  platform: ruby
6
- authors:
11
+ authors:
7
12
  - Mathias Dalheimer
8
- autorequire:
13
+ autorequire: !!null
9
14
  bindir: bin
10
15
  cert_chain: []
11
-
12
- date: 2010-06-08 00:00:00 +02:00
16
+ date: 2011-11-09 00:00:00.000000000 +01:00
13
17
  default_executable: flukso_query
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
16
20
  name: httparty
21
+ requirement: &74856550 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ segments:
28
+ - 0
17
29
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 0.4.3
24
- version:
25
- - !ruby/object:Gem::Dependency
30
+ prerelease: false
31
+ version_requirements: *74856550
32
+ - !ruby/object:Gem::Dependency
33
+ name: crack
34
+ requirement: &74856170 !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ segments:
41
+ - 0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: *74856170
45
+ - !ruby/object:Gem::Dependency
26
46
  name: sqlite3-ruby
47
+ requirement: &74855780 !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ segments:
54
+ - 0
27
55
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 1.2.5
34
- version:
35
- description: This gem provides a library for the Flukso API. See http://flukso.net for more information.
56
+ prerelease: false
57
+ version_requirements: *74855780
58
+ - !ruby/object:Gem::Dependency
59
+ name: shoulda
60
+ requirement: &74855330 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ segments:
67
+ - 0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *74855330
71
+ description: This gem provides a library for the Flukso API. See http://flukso.net
72
+ for more information.
36
73
  email: md@gonium.net
37
- executables:
74
+ executables:
38
75
  - flukso_archive_watts
39
76
  - flukso_create_db
40
77
  - flukso_export_db
41
78
  - flukso_query
42
79
  extensions: []
43
-
44
- extra_rdoc_files:
80
+ extra_rdoc_files:
45
81
  - LICENSE
46
82
  - README.rdoc
47
- files:
83
+ files:
48
84
  - LICENSE
49
85
  - README.rdoc
50
86
  - Rakefile
51
87
  - VERSION
52
88
  - etc/flukso4rrc
53
89
  - lib/flukso.rb
90
+ - lib/flukso/R.rb
54
91
  - lib/flukso/api.rb
55
92
  - lib/flukso/database.rb
56
93
  - lib/flukso/export.rb
57
94
  - lib/flukso/http_auth.rb
95
+ - lib/flukso/plots.rb
58
96
  - lib/flukso/reading.rb
59
97
  - lib/flukso/request.rb
60
98
  - test/helper.rb
61
99
  - test/test_flukso4r.rb
100
+ - bin/flukso_archive_watts
101
+ - bin/flukso_create_db
102
+ - bin/flukso_export_db
103
+ - bin/flukso_query
62
104
  has_rdoc: true
63
105
  homepage: http://gonium.net/md/flukso4r
64
106
  licenses: []
65
-
66
- post_install_message:
67
- rdoc_options:
68
- - --charset=UTF-8
69
- require_paths:
107
+ post_install_message: !!null
108
+ rdoc_options: []
109
+ require_paths:
70
110
  - lib
71
- required_ruby_version: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: "0"
76
- version:
77
- required_rubygems_version: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: "0"
82
- version:
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
118
+ - 0
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
126
+ - 0
83
127
  requirements: []
84
-
85
- rubyforge_project:
86
- rubygems_version: 1.3.5
87
- signing_key:
128
+ rubyforge_project: !!null
129
+ rubygems_version: 1.3.7
130
+ signing_key: !!null
88
131
  specification_version: 3
89
132
  summary: A Ruby Library for the Flukso Webservice
90
- test_files:
91
- - test/helper.rb
92
- - test/test_flukso4r.rb
133
+ test_files: []