Class: Longjing::PDDL::Formula

Inherits:
Literal
  • Object
show all
Defined in:
lib/longjing/pddl/literal.rb

Instance Attribute Summary collapse

Attributes inherited from Literal

#ff_goal, #ff_layer, #ff_neg_goal

Instance Method Summary collapse

Methods inherited from Literal

#applicable?, #apply, #to_a

Constructor Details

#initialize(pred, vars) ⇒ Formula

Returns a new instance of Formula.



82
83
84
85
86
# File 'lib/longjing/pddl/literal.rb', line 82

def initialize(pred, vars)
  @pred = pred
  @vars = vars
  @hash = [pred, vars].hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



81
82
83
# File 'lib/longjing/pddl/literal.rb', line 81

def hash
  @hash
end

#predObject (readonly)

Returns the value of attribute pred.



81
82
83
# File 'lib/longjing/pddl/literal.rb', line 81

def pred
  @pred
end

#varsObject (readonly)

Returns the value of attribute vars.



81
82
83
# File 'lib/longjing/pddl/literal.rb', line 81

def vars
  @vars
end

Instance Method Details

#inspectObject



96
97
98
# File 'lib/longjing/pddl/literal.rb', line 96

def inspect
  "(formula #{to_s})"
end

#substitute(variables) ⇒ Object



88
89
90
# File 'lib/longjing/pddl/literal.rb', line 88

def substitute(variables)
  Fact[@pred, @vars.map{|v| variables[v]}]
end

#to_sObject



92
93
94
# File 'lib/longjing/pddl/literal.rb', line 92

def to_s
  "(#{[@pred.name, *@vars].join(' ')})"
end