예제 #1
0
 def visitExpression_t(self, ctx: pddl22Parser.Expression_tContext):
     hasht = ExprBase(expr_type=ExprBase.ExprType.SPECIAL, special_type=ExprBase.SpecialType.HASHT)
     if ctx.expression():
         binary_op = ExprBase(expr_type=ExprBase.ExprType.BINARY_OPERATOR, op=ExprBase.BinaryOperator.MUL)
         expr = self.visit(ctx.expression())
         return ExprComposite([binary_op,hasht]+expr.tokens)
     else:
         return ExprComposite([hasht])
예제 #2
0
 def set_constant_duration(self, duration: float):
     lhs = ExprComposite([
         ExprBase(expr_type=ExprBase.ExprType.SPECIAL,
                  special_type=ExprBase.SpecialType.DURATION)
     ])
     rhs = ExprComposite([
         ExprBase(expr_type=ExprBase.ExprType.CONSTANT, constant=duration)
     ])
     self.duration = DurationInequality(
         Inequality(comparison_type=Inequality.ComparisonType.EQUALS,
                    lhs=lhs,
                    rhs=rhs))
예제 #3
0
파일: parser.py 프로젝트: taskplanning/otpl
 def visitGround_function_expression_binary(
         self, ctx: pddl22Parser.Ground_function_expression_binaryContext):
     binary_op = ExprBase(expr_type=ExprBase.ExprType.BINARY_OPERATOR)
     binary_op.op = ExprBase.BinaryOperator(ctx.binary_operator().getText())
     lhs = self.visit(ctx.ground_function_expression()[0])
     rhs = self.visit(ctx.ground_function_expression()[1])
     return ExprComposite([binary_op] + lhs.tokens + rhs.tokens)
예제 #4
0
파일: parser.py 프로젝트: taskplanning/otpl
 def visitExpression_durative_operator(
         self, ctx: pddl22Parser.Expression_durative_operatorContext):
     binary_op = ExprBase(expr_type=ExprBase.ExprType.BINARY_OPERATOR)
     binary_op.op = ExprBase.BinaryOperator(ctx.binary_operator().getText())
     lhs = self.visit(ctx.expression_durative()[0])
     rhs = self.visit(ctx.expression_durative()[1])
     return ExprComposite([binary_op] + lhs.tokens + rhs.tokens)
예제 #5
0
 def visitGround_function_expression_function(self, ctx: pddl22Parser.Ground_function_expression_functionContext):
     expr = ExprBase(expr_type=ExprBase.ExprType.FUNCTION)
     name = ctx.name()[0].getText()
     params = []
     for param in ctx.name()[1:]:
         params.append(TypedParameter("TODO parse tables", "TODO parse tables", param.getText()))
     expr.function = AtomicFormula(name, params)
     return ExprComposite([expr])
예제 #6
0
파일: parser.py 프로젝트: taskplanning/otpl
 def visitSimple_duration_constraint_simple(
         self, ctx: pddl22Parser.Simple_duration_constraint_simpleContext):
     comparison_type = Inequality.ComparisonType(
         ctx.duration_op().getText())
     token = ExprBase(expr_type=ExprBase.ExprType.SPECIAL,
                      special_type=ExprBase.SpecialType.DURATION)
     lhs = ExprComposite([token])
     rhs = self.visit(ctx.expression())
     return DurationInequality(Inequality(comparison_type, lhs, rhs))
예제 #7
0
 def add_assign_effect(self,
                       function: AtomicFormula,
                       time_spec: TimeSpec = TimeSpec.AT_START,
                       assign_type: AssignmentType = AssignmentType.ASSIGN,
                       value: float = 1.0):
     """
     Adds a numeric effect.
     If the operator already has a non-conjunctive effect then the new and existing
     effects will be wrapped together within a new conjunctive effect.
     """
     value_expr = ExprComposite(
         [ExprBase(expr_type=ExprBase.ExprType.CONSTANT, constant=value)])
     effect = Assignment(assign_type, function, value_expr)
     if self.durative: effect = TimedEffect(time_spec, effect)
     if self.effect.effect_type == EffectType.CONJUNCTION:
         self.effect: EffectConjunction
         self.effect.effects.append(effect)
     elif self.effect.effect_type == EffectType.EMPTY:
         self.effect = effect
     else:
         self.effect = EffectConjunction(effects=[self.effect, effect])
예제 #8
0
 def visitGround_function_expression_total_time(self, ctx: pddl22Parser.Ground_function_expression_total_timeContext):
     token = ExprBase(expr_type=ExprBase.ExprType.SPECIAL, special_type=ExprBase.SpecialType.TOTAL_TIME)
     return ExprComposite([token])
예제 #9
0
 def visitGround_function_expression_uminus(self, ctx: pddl22Parser.Ground_function_expression_uminusContext):
     uminus = ExprBase(expr_type=ExprBase.ExprType.UMINUS)
     return ExprComposite([uminus] + self.visit(ctx.ground_function_expression()))
예제 #10
0
 def visitGround_function_expression_number(self, ctx: pddl22Parser.Ground_function_expression_numberContext):
     number = ExprBase(expr_type=ExprBase.ExprType.CONSTANT, constant=float(ctx.number().getText()))
     return ExprComposite([number])
예제 #11
0
 def visitExpression_durative_duration(self, ctx: pddl22Parser.Expression_durative_durationContext):
     return ExprComposite([ExprBase(
                 expr_type=ExprBase.ExprType.SPECIAL,
                 special_type=ExprBase.SpecialType.DURATION)])
예제 #12
0
 def visitExpression_durative_uminus(self, ctx: pddl22Parser.Expression_durative_uminusContext):
     uminus = ExprBase(expr_type=ExprBase.ExprType.UMINUS)
     return ExprComposite([uminus] + self.visit(ctx.expression_durative()))
예제 #13
0
 def visitExpression_function(self, ctx: pddl22Parser.Expression_functionContext):
     expr = ExprBase(expr_type=ExprBase.ExprType.FUNCTION)
     expr.function = self.visit(ctx.atomic_formula())
     return ExprComposite([expr])