-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implement parallel exploration of the computation tree #4
Comments
OK, this just cannot be done as such. Even in simple examples (e.g., k-colouring K_5) too many processes are generated, giving a |
Reopened the issue: I’ll try actual dovetailing (execute the computation on the 1st choice for 1 × time quantum, then the computation on the 1st choice for 2 × time quantum and the computation on the 1st choice for 2 × time quantum, etc…). This should clearly work, the question is how to do it under Unix (alarms & signals, I suppose?) and if it is fast enough in practice. |
I had also wondered about how to handle this several years ago, so I'll share my thoughts. I had a vague idea (not very well thought out) about using depth-limited DFS, which is something like dovetailing. I was thinking about doing it without multiple processes, instead manipulating the runtime stack to save and restore back to known states when needed. This is where I got stuck; I could not find a way of saving/restoring the Python runtime stack. In any event, what I was thinking about would require some kind of cooperative multitasking, which may not be easy to implement or get to work well. As I said, just some thoughts that I had; they are probably not that practical. |
Thanks for your thoughts! I am also looking for a possible implementation without multiprocessing, which would certainly improve the performances of the library as a side effect. Your solution does indeed work in principle, and I’ve actually already seen an implementation of nondeterminism in C using Python also has coroutines (both in terms of generators and now with My main requirement for this library is that the interface must absolutely be:
for pedagogical and elegance reasons. Other solutions, which are certainly cleaner and faster in terms of implementation, but seem to require explicitly creating and passing around some “guesser” object, are this recent nondet library and this implementation of the amb operator on Rosetta Code. |
Currently, the computation tree is explored sequentially depth-first, which means that if we run into a nonterminating branch, the program will not terminate even if there exists a terminating and accepting branch elsewhere.
This can be solved by exploring the tree in parallel (i.e., running the child processes in parallel) but requires recursively terminating all other descendants as soon as an accepting computation halts.
The text was updated successfully, but these errors were encountered: