Replies: 3 comments 3 replies
-
Hello @makaimann! This is actually not really a Python issue at all. Distance matrix of 40k distances will take a while to process into the representation that the solver needs - and what you're calling "a hang" is the solver doing just that. This is likely to happen in Java as well, but given the performance difference between the two, it may be significantly less noticeable there. That said, the bigger the matrix, the worse this will get. What I find interesting though is... how are you using nearby selection, since it is an Enterprise Edition feature? In the Community Edition of the solver, you should have had no access to it. Could it be that you're not actually talking about the nearby selection feature? If that were the case, then this cache you're speaking about would be purely an issue of user code, having nothing to do with the solver - and in that case, I have no idea what's taking so long, since I have not seen the code. |
Beta Was this translation helpful? Give feedback.
-
Greetings @makaimann ! What is happening is the Solver is converting the Python dictionary to a Java Map. This happens when solve is first called, since that when it converts the Python objects and functions into equivalent Java objects and functions. |
Beta Was this translation helpful? Give feedback.
-
That makes a lot of sense, thank you both for the very quick response! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey Timefold team!
First, I want to acknowledge that I saw the announcement that you're halting active development on the Python API, so I apologize for asking a question related to it. But for now, I have an encoding that I haven't moved over to Java yet. My goal is for this to be the last Python API question I ever ask 😆
I just identified that a distance cache in a Python encoding (dictionary to look up distances between planning entity instances) is causing a noticeable delay before solving. If the cache grows large (~10k+) then there's a nontrivial hang when calling
solve
before getting anyINFO
logs that solving has started. With a cache containing 40k distances I was seeing a hang of about 12 seconds.I experimented with storing the dictionary in each entity (it's Python so it's a pointer of course) or with making it a global variable. Regardless it seems to hang.
Do you have any recommendations / suggested design patterns? I could always just drop the cache and re-compute distances each time if there's no way around this.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions