diff --git a/up_tamer/converter.py b/up_tamer/converter.py index d31e835..055a4ff 100644 --- a/up_tamer/converter.py +++ b/up_tamer/converter.py @@ -142,8 +142,11 @@ def walk_int_constant(self, expression: 'FNode', def walk_plus(self, expression: 'FNode', args: List[pytamer.tamer_expr]) -> pytamer.tamer_expr: - assert len(args) == 2 - return pytamer.tamer_expr_make_plus(self._env, args[0], args[1]) + assert len(args) > 0 + res = args[0] + for i in range(1, len(args)): + res = pytamer.tamer_expr_make_plus(self._env, res, args[i]) + return res def walk_minus(self, expression: 'FNode', args: List[pytamer.tamer_expr]) -> pytamer.tamer_expr: @@ -152,8 +155,11 @@ def walk_minus(self, expression: 'FNode', def walk_times(self, expression: 'FNode', args: List[pytamer.tamer_expr]) -> pytamer.tamer_expr: - assert len(args) == 2 - return pytamer.tamer_expr_make_times(self._env, args[0], args[1]) + assert len(args) > 0 + res = args[0] + for i in range(1, len(args)): + res = pytamer.tamer_expr_make_times(self._env, res, args[i]) + return res def walk_div(self, expression: 'FNode', args: List[pytamer.tamer_expr]) -> pytamer.tamer_expr: diff --git a/up_tamer/engine.py b/up_tamer/engine.py index 0cb7f84..e3a0976 100644 --- a/up_tamer/engine.py +++ b/up_tamer/engine.py @@ -404,9 +404,17 @@ def _convert_action(self, problem: 'up.model.Problem', action: 'up.model.Action' expressions.append(expr) for t, le in action.effects.items(): for e in le: - assert not e.is_conditional() and e.is_assignment() - ass = pytamer.tamer_expr_make_assign(self._env, converter.convert(e.fluent), - converter.convert(e.value)) + assert not e.is_conditional() + if e.is_assignment(): + ass = pytamer.tamer_expr_make_assign(self._env, converter.convert(e.fluent), converter.convert(e.value)) + elif e.is_increase(): + val = pytamer.tamer_expr_make_plus(self._env, converter.convert(e.fluent), converter.convert(e.value)) + ass = pytamer.tamer_expr_make_assign(self._env, converter.convert(e.fluent), val) + elif e.is_decrease(): + val = pytamer.tamer_expr_make_minus(self._env, converter.convert(e.fluent), converter.convert(e.value)) + ass = pytamer.tamer_expr_make_assign(self._env, converter.convert(e.fluent), val) + else: + raise NotImplementedError expr = pytamer.tamer_expr_make_temporal_expression(self._env, self._convert_timing(t), ass)