Class: Longjing::FF::Preprocess

Inherits:
Object
  • Object
show all
Defined in:
lib/longjing/ff/preprocess.rb

Defined Under Namespace

Modules: NegGoal

Instance Method Summary collapse

Instance Method Details

#execute(problem) ⇒ Object



16
17
18
19
20
# File 'lib/longjing/ff/preprocess.rb', line 16

def execute(problem)
  ret = propositionalize(problem)
  reverse_negative_goals(ret.goal)
  ret
end

#propositionalize(problem) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/longjing/ff/preprocess.rb', line 22

def propositionalize(problem)
  actions = problem[:actions].map do |action|
    params = Parameters.new(action)
    params.propositionalize(problem[:objects])
  end.flatten
  Problem.new(actions, problem[:init], problem[:goal])
end

#reverse_negative_goals(goal) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/longjing/ff/preprocess.rb', line 30

def reverse_negative_goals(goal)
  case goal
  when PDDL::And
    goal.literals.each do |lit|
      reverse_negative_goals(lit)
    end
  when PDDL::Not
    goal.extend(NegGoal)
    goal.ff_neg_goal = true
  end
end