Class: DummyEvaluator

Inherits:
Evaluator show all
Defined in:
lib/dummy_evaluator.rb

Overview

This is a simple evaluator for debugging. It generates an array of the values of flags and adds the indices of all flags that are boolean and true and puts them in the formula exp(sqrt(x)).

Instance Attribute Summary

Attributes inherited from Evaluator

#phase

Instance Method Summary collapse

Methods inherited from Evaluator

#load_cache, #save_cache, #step

Constructor Details

#initializeDummyEvaluator

Returns a new instance of DummyEvaluator.


8
9
10
11
12
13
14
# File 'lib/dummy_evaluator.rb', line 8

def initialize()
  super "", # algo_name
    "", "", # folder_{compile,eval}
    "", "", # build_cmdline_{compile,eval}
    {}, "", "", # versions, standard_flags, storage
    "", "" # host_group_{compile,eval}
end

Instance Method Details

#[](flags_array) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dummy_evaluator.rb', line 17

def [](flags_array)
  if $DUMMY_COUNTER == nil then
    $DUMMY_COUNTER = 0
  end
  $DUMMY_COUNTER += 1
  group = "dummygroup-#{$DUMMY_COUNTER}"
  $JOBMANAGER.init_group group
  job = LocalJob.new "dummy job", group, lambda {}
  $JOBMANAGER.submit job
  $JOBMANAGER.finish_group group

  flags_array.map do |flags|
    flags.to_a.values.each_with_index.map do |value, index|
      value ? Math.exp(Math.sqrt(index)) : 0
    end.reduce(:+)
  end
end