Class: OptimizeTask

Inherits:
Object
  • Object
show all
Includes:
LoggedClass
Defined in:
lib/optimize_task.rb

Overview

This class represents the settings and environment of a single optimization run.

All variables of an optimization run can be loaded from an file using this class.

For a description of the format of this file see the format documentation

Constant Summary

Constants included from LoggedClass

LoggedClass::LoggedClasses

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LoggedClass

#debug, #error, #fatal, generate_outputter_config, included, #info, #warn

Constructor Details

#initializeOptimizeTask

Returns a new instance of OptimizeTask.


23
24
25
26
# File 'lib/optimize_task.rb', line 23

def initialize()
  @flag_set = FlagSet.new
  @excluded_groups = []
end

Instance Attribute Details

#flag_setObject (readonly)


21
22
23
# File 'lib/optimize_task.rb', line 21

def flag_set
  @flag_set
end

#nameObject (readonly)


21
22
23
# File 'lib/optimize_task.rb', line 21

def name
  @name
end

Instance Method Details

#load_state(file) ⇒ Object


76
77
78
# File 'lib/optimize_task.rb', line 76

def load_state(file)
  @algorithm.load_state(file)
end

#read_from_file(filename) ⇒ Object

Reads an optimization task from a file. For the file format see the format documentation.

Parameters:

  • filename (String)

    The name of the file to be read from.

See Also:

  • Format documentation}.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/optimize_task.rb', line 32

def read_from_file(filename)
  debug "reading task from file #{filename}"
  doc = REXML::Document.new open(filename)
  doc.elements.each("optimize-task") do |elem|
    @name = elem.attributes["name"]
    @standard_flags = elem.elements["standard-flags"].text
    @standard_flags = "" if @standard_flags.nil?
    @host_group_compile = elem.elements["host-group-compile"].text
    @host_group_eval = elem.elements["host-group-eval"].text
    @folder_compile = elem.elements["folder-compile"].text
    @folder_eval = elem.elements["folder-eval"].text
    @storage = elem.elements["storage"].text

    read_versions_map elem.elements["versions"]

    elem.elements.each("exclude-flag-group") do |group|
      @excluded_groups << group.text
    end

    elem.elements.each("flag-set") do |set|
      add_flag_set($FLAGSETS[set.text])
    end

    algorithm = elem.elements["algorithm"].text
    algorithm_values = elem.elements["algorithm-values"].text
    termination_criterion_type =
      elem.elements["termination-criterion"].attributes["type"]
    termination_criterion_value =
      elem.elements["termination-criterion"].text
    evaluator = elem.elements["evaluator"].text

    read_evaluator evaluator, algorithm

    read_algorithm algorithm, algorithm_values,
      termination_criterion_type, termination_criterion_value
  end
end

#run(*args) ⇒ Object

Executes the loaded optimization run

Parameters:

  • filename (String)

    The filename of the file that the result should be written to.


72
73
74
# File 'lib/optimize_task.rb', line 72

def run(*args)
  @algorithm.run *args
end