Class: Tensai::Pddl::AtomicFormula

Inherits:
Object
  • Object
show all
Defined in:
lib/tensai/pddl/atomic_formula.rb

Overview

Atomic formula in a planning domain

Instance Method Summary collapse

Constructor Details

#initialize(predicate, terms) ⇒ AtomicFormula

Returns a new instance of AtomicFormula.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
# File 'lib/tensai/pddl/atomic_formula.rb', line 18

def initialize(predicate, terms)
  super predicate, terms

  raise ArgumentError, 'Unknown Terms' if terms.keys.any? { |k| !predicate.variables.key?(k) }

  predicate.variables.each do |var|
    self.terms[var.name] = var unless terms.key? var.name
  end
  self.terms.freeze
end

Instance Method Details

#bind(values) ⇒ Object



29
30
31
# File 'lib/tensai/pddl/atomic_formula.rb', line 29

def bind(values)
  AtomicFormula.new(predicate, terms.merge(values))
end