Class: Longjing::PDDL::And

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

Constructor Details

#initialize(literals) ⇒ And

Returns a new instance of And.



172
173
174
# File 'lib/longjing/pddl/literal.rb', line 172

def initialize(literals)
  @literals = literals
end

Instance Attribute Details

#literalsObject (readonly)

Returns the value of attribute literals.



170
171
172
# File 'lib/longjing/pddl/literal.rb', line 170

def literals
  @literals
end

Instance Method Details

#applicable?(set) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
179
180
# File 'lib/longjing/pddl/literal.rb', line 176

def applicable?(set)
  @literals.all? do |lit|
    lit.applicable?(set)
  end
end

#apply(set) ⇒ Object



182
183
184
185
186
187
188
# File 'lib/longjing/pddl/literal.rb', line 182

def apply(set)
  ret = set.dup
  @literals.each do |lit|
    lit.apply(ret)
  end
  ret
end

#inspectObject



215
216
217
# File 'lib/longjing/pddl/literal.rb', line 215

def inspect
  "(and #{@literals.map(&:inspect).join(" ")})"
end

#substitute(variables) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/longjing/pddl/literal.rb', line 190

def substitute(variables)
  ret = []
  @literals.each do |lit|
    n = lit.substitute(variables)
    return nil if n.nil?
    next if n == EMPTY
    ret << n
  end
  if ret.empty?
    nil
  elsif ret.size == 1
    ret[0]
  else
    And.new(ret)
  end
end

#to_aObject



207
208
209
# File 'lib/longjing/pddl/literal.rb', line 207

def to_a
  @literals
end

#to_sObject



211
212
213
# File 'lib/longjing/pddl/literal.rb', line 211

def to_s
  "(and #{@literals.map(&:to_s).join(" ")})"
end