-
Notifications
You must be signed in to change notification settings - Fork 254
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
Variable data attribute not accessible through Model.getVars() #270
Comments
yes, the problem here is that every time you get a variable from SCIP, PySCIPOpt creates a new Variable object. Some time ago we discussed how to keep a single variable object but we didn't decide on anything. I guess now is the time for talking again about this. Since variables have vardata (internally in SCIP) I guess one solution would be to store the python Variable in the vardata. I guess a more homogeneous solution would be to store a mapping between the SCIP data and the python data. @mattmilten any thoughts? |
I am definitely in favor of storing a mapping in Python. This could lead to a more expensive lookup whenever you want to get the data, though. Another solution is to store the variables (including their data) inside the model data:
Then, when you want to retrieve them you don't need to call |
the problem with storing it in m.data is what happens when you read a problem from a file. There was an issue about this, but can't find it anymore |
I just tested reading in a model and storing something in a variable and then storing all variables in the model data. All works fine. |
If it is stored in |
Well, if you store the variables in It might happen, that for some reason the |
I belive the same thing happens when I try to store an attribute in a node = model.getCurrentNode()
print(node.data) ? |
Yes, unfortunately this is currently the case. I understand that with Nodes my work around from above does not make much sense either. We need to make these objects persistent. |
Would using a constraint handler as outlined in the SCIP FAQ work for now in PySCIPOpt or are there any further pitfalls? |
that should work. I translated the coloring example of SCIP to pyscipopt some time ago. You can have a look in the branch |
I don't know what you are trying to implement. In general a constraint handler should work because the entire constraint handler is stored within SCIP itself using the constraint handler data. This should be the case for all the plugins. I suppose we really need to implement this functionality also for the simpler objects, like Node or Variable. |
In #268 the
.data
attribute was added to the Variable class, but this attribute is not accessible viaModel.getVars()
. See the following MWE:actual output:
expected output:
Note that similar issues might exist for the other classes adapted in #268
The text was updated successfully, but these errors were encountered: