Example #1
0
 def add_assign_effect_from_str(
         self,
         name: str,
         parameters: dict[str, str] = {},
         constants: dict[str, str] = {},
         time_spec: TimeSpec = TimeSpec.AT_START,
         assign_type: AssignmentType = AssignmentType.ASSIGN,
         value: float = 1.0):
     """
     Adds a numeric effect from string using AtomicFormula.from_string()
     param name: the name of the predicate to add.
     param parameters: dictionary mapping label to type.
     param constants: dictionary mapping label to constant value.
     param time_spec: timing of effect, if durative action.
     param assign_type: the type of numeric assignment (assign, increase, decrease, etc)
     param value: The amount to be applied.
     """
     self.add_assign_effect(
         AtomicFormula.from_string(name, parameters, constants), time_spec,
         assign_type, value)
Example #2
0
    def visitDurative_action_def(self, ctx:pddl22Parser.Durative_action_defContext):

        op_formula = AtomicFormula(ctx.name().getText())
        for param_list in ctx.typed_var_list():
            op_formula.typed_parameters.extend(self.visit(param_list))

        if ctx.durative_action_goal_descriptor():
            condition = self.visit(ctx.durative_action_goal_descriptor())
        else: condition = GoalDescriptor()

        if ctx.durative_action_effect():
            effect = self.visit(ctx.durative_action_effect())
        else: effect = Effect()

        self.operator = Operator(op_formula,
            durative=True,
            duration=self.visit(ctx.duration_constraint()),
            condition=condition,
            effect=effect)
        self.domain.operators.append(self.operator)
Example #3
0
 def visitAtomic_formula(self, ctx:pddl22Parser.Atomic_formulaContext):
     # TODO need a name and variable lookup table to get types
     return AtomicFormula(ctx.name().getText(), typed_parameters=self.visit(ctx.term_list()))
Example #4
0
 def get_pne_from_id(self, id : int) -> AtomicFormula:
     for name in self.function_heads:
         if self.function_heads[name][0] <= id and id < self.function_heads[name][1]:
             id = id - self.function_heads[name][0]
             params = self.domain.functions[name].typed_parameters
             return AtomicFormula(name, self.get_parameters_from_id(id, params), True)