Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alvalentini committed Apr 15, 2024
1 parent 8b7fa42 commit d2b5237
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
14 changes: 10 additions & 4 deletions up_tamer/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions up_tamer/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d2b5237

Please sign in to comment.