CPMpy / cpmpy

Constraint Programming and Modeling library in Python, based on numpy, with direct solver access.
Apache License 2.0
220 stars 22 forks source link

partial functions #439

Open Wout4 opened 9 months ago

Wout4 commented 9 months ago

We have decided we want to be able to support relational semantics for partial functions in cpmpy, this is however a long term goal. For now the use of partial functions will be restricted to it's safe domain, to ensure backwards compatibility.

You can read more about the different semantics for partial functions here: “The Proper Treatment of Undefinedness in Constraint Languages” https://www.cs.york.ac.uk/aig/constraints/AutoModel/undefinedness.pdf

Wout4 commented 9 months ago

For those having trouble with their index being out of bounds: the general solution is to create a new index variable, with the correct bounds, and adding a constraint that equals the new variable to your old index. It is of course better to just reduce the bounds of the index you are using, if possible, since this will avoid the need for extra variables and constraints.