Class: Longjing::PDDL::Fact

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

Constant Summary collapse

@@insts =
{}

Instance Attribute Summary collapse

Attributes inherited from Literal

#ff_goal, #ff_layer, #ff_neg_goal

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Literal

#to_a

Constructor Details

#initialize(pred, objs) ⇒ Fact

Returns a new instance of Fact.



53
54
55
56
57
# File 'lib/longjing/pddl/literal.rb', line 53

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

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



51
52
53
# File 'lib/longjing/pddl/literal.rb', line 51

def hash
  @hash
end

Class Method Details

.[](*args) ⇒ Object



46
47
48
# File 'lib/longjing/pddl/literal.rb', line 46

def [](*args)
  @@insts[args] ||= new(*args)
end

Instance Method Details

#applicable?(set) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/longjing/pddl/literal.rb', line 59

def applicable?(set)
  set.include?(self)
end

#apply(set) ⇒ Object



63
64
65
# File 'lib/longjing/pddl/literal.rb', line 63

def apply(set)
  set << self
end

#inspectObject



75
76
77
# File 'lib/longjing/pddl/literal.rb', line 75

def inspect
  "(fact #{[@pred.name, *@objs].join(' ')})"
end

#substitute(variables) ⇒ Object



67
68
69
# File 'lib/longjing/pddl/literal.rb', line 67

def substitute(variables)
  self
end

#to_sObject



71
72
73
# File 'lib/longjing/pddl/literal.rb', line 71

def to_s
  "(#{[@pred.name, *@objs.map(&:name)].join(' ')})"
end