You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to solve a school timetabling problem using Optapy, but I got the following error:
solution = solver.solve(problem_to_solve)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/d-future/miniconda3/envs/Minerva/lib/python3.11/site-packages/optapy/optaplanner_api_wrappers.py",
line 416, in solve
wrapped_problem = PythonSolver.wrapProblem(object_class, problem)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
org.optaplanner.optapy.org.optaplanner.optapy.OptaPyException: org.optaplanner.optapy.OptaPyException:
A problem occurred when wrapping the python problem
(<jpype._jproxy.proxy.OptaPlannerSchedule object at 0x7ff372e86440>).
Maybe an annotation was passed an incorrect type (for example, @problem_fact_collection_property(str)
on a function that return a list of int).
I have reviewed the code multiple times to find an error like the one described in the msg but I did not succeed. Could you have a quick look at the code below to see if I am missing something? From the error msg, it seems to be something trivial, but it keeps eluding me :S
There's a note at the bottom of section 3.3.1 that warns:
Planning entity __hash__(self) implementations must remain constant. Therefore entity __hash__(self) must not depend on any planning variables. Pay special attention when using data structures with auto-generated __hash__(self) as entities, such as Python @dataclass.
I tried defining a __hash__(self) method for the @planning_entity class, but still not working. Actually, I think the error may have a different nature as @planning_entity is defined as a class, not as @dataclass.
According to the error msg, the issue seems to happen when wrapping the @planning_solution class. However, given your warning about the usage of @dataclass, I wonder if there may be any other side effects when using these with Optapy? I will try to investigate in that direction.
In the meanwhile, if you come up with any other ideas, just let me know, please.
Hi!
I was trying to solve a school timetabling problem using Optapy, but I got the following error:
I have reviewed the code multiple times to find an error like the one described in the msg but I did not succeed. Could you have a quick look at the code below to see if I am missing something? From the error msg, it seems to be something trivial, but it keeps eluding me :S
Thanks in advance!
The text was updated successfully, but these errors were encountered: