Hash code for PPL objects

Hi, I am trying to write a function returning a 32 bit integer hash code for a PPL Semantic Geometric Descriptor. The hash function should be compatible with equality: if two PPL objects are the same according to the == operator, they must have the same hash code.
Unfortunately, I could not find anything particularly useful in the library. My current attempt is to get the string representation of the object and compute an hash value from the latter. However, this works only if equal objects always have equal string representation.
May I assume this holds, even for complex domains such as polyhedra ? Are there better ways to get an hash code ?
Thanks in advance for any help you can provide.
--gianluca amato

Hi Gianluca.
I guess you already did
$ git checkout devel Already on 'devel' Your branch is up to date with 'origin/devel'. $ git grep hash_code
and you did not like what you found, correct? Kind regards,
Roberto
On 9/14/22 09:17, Gianluca Amato wrote:
Hi, I am trying to write a function returning a 32 bit integer hash code for a PPL Semantic Geometric Descriptor. The hash function should be compatible with equality: if two PPL objects are the same according to the == operator, they must have the same hash code.
Unfortunately, I could not find anything particularly useful in the library. My current attempt is to get the string representation of the object and compute an hash value from the latter. However, this works only if equal objects always have equal string representation.
May I assume this holds, even for complex domains such as polyhedra ? Are there better ways to get an hash code ?
Thanks in advance for any help you can provide.
--gianluca amato
PPL-devel mailing list PPL-devel@cs.unipr.it https://www.cs.unipr.it/mailman/listinfo/ppl-devel

Hi Roberto.
On Wed, Sep 14, 2022 at 4:01 PM Roberto Bagnara bagnara@cs.unipr.it wrote:
Hi Gianluca.
I guess you already did
$ git checkout devel Already on 'devel' Your branch is up to date with 'origin/devel'. $ git grep hash_code
and you did not like what you found, correct?
Sorry, I did not thought about checking the source code. I looked for some hash function in the user documentation, but couldn't find any (now I checked the documentation for developers and I see it was there).
Actually, now that I look at the code, it is true that I don't particularly like it. If I understand correctly, at least for polyhedron, boxes and similar domains, the hash is computed by the space dimension. So, it is technically compatible with equality, but not well distributed, just slightly better than a constant function. So, at least for some applications, I think that my question on the consistency of the string representation is still relevant.
Ciao, --gianluca
participants (2)
-
Gianluca Amato
-
Roberto Bagnara