def visit_bipartite_stmt(self, node): fab_decomp = pddl.Effect() disc_decomp = pddl.Effect() fab_formula = node.fab_formula disc_formula = node.disc_formula if fab_formula.key == 'and': for c in fab_formula.children: self.add_decomp(fab_decomp, c) else: self.add_decomp(fab_decomp, fab_formula) if disc_formula.key == 'and': for c in disc_formula.children: self.add_decomp(disc_decomp, c) else: self.add_decomp(disc_decomp, disc_formula) self.set_in(node, fab_decomp) self.set_in(node, disc_decomp)
def visit_effect_stmt(self, node): """ Visits a PDDL effect statement.""" formula = node.formula effect = pddl.Effect() # For now we only allow 'and' in the effect. if formula.key == 'and': for c in formula.children: # Call helper. self.add_effect(effect, c) else: # Call helper. self.add_effect(effect, formula) # Store effect in node. self.set_in(node, effect)
def visit_decomp_stmt(self, node): """Visits a PDDL requirement statement.""" from pddl.parser import Variable decomp = pddl.Effect() formula = node.formula # For now we only allow 'and' in the effect. if formula.key == 'and': for c in formula.children: self.add_decomp(decomp, c) else: self.add_decomp(decomp, formula) # Store precondition in node. self.set_in(node, decomp)
def visit_goal_stmt(self, node): """ Visits a PDDL-problem goal state statement.""" formula = node.formula goal = pddl.Effect() #to enable delete list # For now we only allow 'and' in the goal. if formula.key == 'and': for c in formula.children: if not isinstance(c.key, str): raise SemanticError('Error predicate with non str key: ' + ''.join([c2.key.name + ' ' for c2 in formula.children])) # Call helper. self.add_goal(goal, c) else: # Only a single predicate is allowed then (s.a.) if not formula.key in self._domain.predicates: raise SemanticError('Error: predicate in goal definition is ' 'not in CNF') # Call helper. self.add_goal(goal, formula) self.set_in(node, goal)
def visit_precondition_stmt(self, node): """ Visits a PDDL precond statement.""" precond = pddl.Effect() formula = node.formula if formula.key in {'forall', 'for-all'}: pass # For now we only allow 'and' in the effect. if formula.key == 'and': for c in formula.children: # Call helper. if c.key in {'equals', 'equal', '='}: continue self.add_precond(precond, c) else: # Call helper. #if formula.key in {'forall', 'for-all', 'exists', 'equals', '=', 'equal'}: if not formula.key in {'equals', 'equal', '='}: self.add_precond(precond, formula) # Store precondition in node. self.set_in(node, precond)