Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash of aries engine integration code when adding timed effects #536

Closed
nicola-gigante opened this issue Dec 1, 2023 · 3 comments · Fixed by #538
Closed

Crash of aries engine integration code when adding timed effects #536

nicola-gigante opened this issue Dec 1, 2023 · 3 comments · Fixed by #538

Comments

@nicola-gigante
Copy link

nicola-gigante commented Dec 1, 2023

Describe the bug
The aries engine integration crashes when a timed effect is added to a problem.

To Reproduce
Run the following:

import unified_planning as up
from unified_planning.shortcuts import *
from unified_planning.model.htn import *

problem = HierarchicalProblem()

done = Fluent('done', BoolType())
problem.add_fluent(done)
problem.set_initial_value(done, False)

problem.add_timed_effect(
    Timing(60, Timepoint(TimepointKind.GLOBAL_START)), done, True
)

print(problem.timed_effects)

with OneshotPlanner(name='aries') as planner:
    res = planner.solve(problem)
    print(res)

The output is the following:

{start + 60: [done := true]}
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ngigante/projects/telaio/backend/planning/models/issue.py", line 19, in <module>
    res = planner.solve(problem)
  File "/home/ngigante/projects/telaio/.venv/lib/python3.9/site-packages/unified_planning/engines/mixins/oneshot_planner.py", line 80, in solve
    return self._solve(problem, heuristic, timeout, output_stream)
  File "/home/ngigante/projects/telaio/.venv/lib/python3.9/site-packages/up_aries/solver.py", line 347, in _solve
    server, req = self._prepare_solving(problem, heuristic, timeout, output_stream)
  File "/home/ngigante/projects/telaio/.venv/lib/python3.9/site-packages/up_aries/solver.py", line 310, in _prepare_solving
    proto_problem = self._writer.convert(problem)
  File "/home/ngigante/projects/telaio/.venv/lib/python3.9/site-packages/unified_planning/grpc/converter.py", line 37, in convert
    return f(element, *args)
  File "/home/ngigante/projects/telaio/.venv/lib/python3.9/site-packages/unified_planning/grpc/proto_writer.py", line 587, in _convert_problem
    return proto.Problem(
TypeError: Parameter to MergeFrom() must be instance of same class: expected <class 'unified_planning_pb2.TimedEffect'> got <class 'unified_planning_pb2.Timing'>.

Since MergeFrom is a protobuf function and the aries integration uses protobuf to communicate to the backend, I suspect this is a problem in the conversion of the UP Problem class to the unified_planning.grpc.generated.unified_planning_pb2.Problem class.

Note that the fact that I'm creating a HierarchicalProblem here is irrelevant.
The same happens if I create a simple Problem.

Expected behavior
I would expect to get whatever result the planning problem has, instead of an exception.

Additional context
I'm on Python 3.9 on Debian Linux.

@mikand
Copy link
Member

mikand commented Dec 4, 2023

@arbimo FYK

@Framba-Luca
Copy link
Contributor

@nicola-gigante The bug you are experiencing comes from the UP.

It should be fixed in the pr #538.

@nicola-gigante
Copy link
Author

nicola-gigante commented Dec 4, 2023

Thanks! Is there a timeframe for the PR to be merged into a release of the UP?

Edit: I didn't realize the PR was brand new! You have been super fast! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants