Skip to content

Conversation

@ThomSerg
Copy link
Collaborator

@ThomSerg ThomSerg commented Dec 2, 2025

Calling .value() on and expression containing abs will currently throw an error if it contains a None. This can occur when a model is UNSAT and one tries to call .value() on one of its expressions afterwards (one containing an abs). Fixed implementation such that the abs will correctly also return None.

@ThomSerg ThomSerg added bug simple to review Simple change to review, e.g., a oneliner. labels Dec 2, 2025
Copy link
Collaborator

@IgnaceBleukx IgnaceBleukx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, I suppose this is can actually happen for all of our globals?
We should check this explicitly when calling the value of any expression...

We currently do it for some but not all... Not all will actually return an error, but the value could be wrong...
E.g., for alldifferent, we check the value as len(set(argvals)) == len(self.args), so if there is one argument that has value None, this check will still be valid...

I you want to go through the other globals fixing it similarly to this one, that would be great, but otherwise fine to just open an issue for that and merge this already : )

self.x[0]._value = 0
self.assertEqual(gt.value(), 0)
self.x[0]._value = None
self.assertEqual(gt.value(), None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use assertIsNone here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug simple to review Simple change to review, e.g., a oneliner.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants