Class: OMF::Rete::Planner::PlanLevelBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/omf_rete/planner/plan_level_builder.rb

Overview

This class builds all the possible plans for a given level of the plan forest.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sources) ⇒ PlanLevelBuilder

fullCover – Set of all sources to cover



17
18
19
20
21
# File 'lib/omf_rete/planner/plan_level_builder.rb', line 17

def initialize(sources)
  @fullCover = sources
  @complete_plans = []
  @plans = sources.clone
end

Instance Attribute Details

#complete_plansObject (readonly)

Returns the value of attribute complete_plans.



13
14
15
# File 'lib/omf_rete/planner/plan_level_builder.rb', line 13

def complete_plans
  @complete_plans
end

#plansObject (readonly)

Returns the value of attribute plans.



13
14
15
# File 'lib/omf_rete/planner/plan_level_builder.rb', line 13

def plans
  @plans
end

Instance Method Details

#buildObject

Array of sources from lower levels to build new plans from

plans -- array of plans to combine
fullCoverSet -- set containing all initial sources


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/omf_rete/planner/plan_level_builder.rb', line 29

def build()
  plans = @plans.to_a
  plans.each_with_index do |plan, i|
    unless (rem = plans[i + 1 .. -1]).nil?
      build_for_plan(plan, rem)
    end
    unless plan.used?
      add_plan(plan)
    end
  end
  @plans
end

#describe(out = STDOUT, offset = 0, incr = 2, sep = "\n") ⇒ Object



42
43
44
45
46
# File 'lib/omf_rete/planner/plan_level_builder.rb', line 42

def describe(out = STDOUT, offset = 0, incr = 2, sep = "\n")
  @plans.each do |p|
    p.describe(out, offset, incr, sep)
  end
end