-
Notifications
You must be signed in to change notification settings - Fork 25
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
UUID #402
base: master
Are you sure you want to change the base?
Conversation
I think this will also be useful for the CSE, as you can then create easily a unique hash for each expression based on the type of operation and the argument of it |
defining a unique hash for every expression is a great idea, should probably go in another pr though |
cpmpy/expressions/variables.py
Outdated
return hash(self.name) | ||
# for backwards compatability | ||
if not hasattr(self, 'id'): | ||
self.id = self.id = uuid.uuid4() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
This is hard to review because of the autoformatting changes. Would it be possible to add these in a separate MR? Also, provide an explanation for all collaborators on how to use the same autoformatter, so that the autoformatting does not get broken in future MRs. |
Replace |
I'm lukewarm on using a However, this is just an optimization issue, so if you think the current approach is fine, that's fine by me. |
global variable counter does not work with pickled models, as the counter is not pickled. For example, you define a first model with variable id 1 to 10, counter is at 10, you pickle the model, fine. Then you unpickle it in another run, counter is resetted, you decide to add new var to model, var id 1 reused, conflict |
Ah, did not think of that. The counter is indeed part of the state and should be pickled too, but I can see that this may tip the scales in the balance between simplicity and efficiency. |
I will try to make a case again for why we need unique identifiers :) (to implement CSE) After looking into python dicts/sets it turns out that in the event of a hash collision On the other hand, we could use something else as the key, to avoid the problem with overwriting eq. But then we would still need a unique property of expressions to use as the key, since the string representation could not be unique (when the user gives particular names or descriptions to the variables/expressions) (-> uuid needed) |
Added an ID fields to variables, using uuid to get unique id's.
Naming stays the same, for display/print reasons.
When posting to the solver I decided to use name + id because
Let me know if you think this is silly.