-
Notifications
You must be signed in to change notification settings - Fork 68
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
PySCIPOpt callbacks and Model lifetime #225
Comments
Adding an attribute might be a bit trickier than it seems because the oject is a C++ one, but perhaps a keep alive policy could help here. |
I've successfully reproduce the problem in a test in #281. The problem is that PySCIPOpt callback use a weak reference (a reference that does not do reference counting) to the PySCIPOpt We have the same problem in the sense that the following code is legal in Ecole pyscipopt_model = next(ecole.instance.SetCoverGenerator()).as_pyscipopt() For this to work, the model = next(ecole.instance.SetCoverGenerator())
model.as_pyscipopt().getSomething() # SCIP* deallocated after this point
model.solve() The correct way to do this would be for Ecole and PySCIPOpt model not to rely on each other for the ownership of the |
Wow, that looks like big progress. Well done @AntoinePrv . Let's discuss what to do with that in the next meeting. |
Discussed in #193
A partial fix has been merged into PySCIPOpt here. Still, I understand that one must keep a reference to the PySCIPOpt object that was used to create the event handler somewhere to use event handlers registered through PySCIPOpt within Ecole (comment here).
What if the
model.as_pyscipopt()
method would store such a reference internally on the first call, and then simply return that reference again on later calls, as long as the SCIP model does not change ? @AntoinePrv do you think that would work ?Best
The text was updated successfully, but these errors were encountered: