lifebeyondfife / Decider

An Open Source .Net Constraint Programming Solver
MIT License
150 stars 21 forks source link

Add meta expression enabling creation of meta constraints. #26

Closed lifebeyondfife closed 4 years ago

lifebeyondfife commented 4 years ago

The constrained array type allows constrained variables to index arrays, providing a rich syntax for describing CSPs. For example, given the variable var_i, with domain [0..5], the user can create an array of exponents and use it to make a constraint:

exponentArray = [1, 10, 100, 1000, 10000, 100000]
constraint = exponentArray[var_i] < 500

Decider examines the contents of each constraint ahead of search and makes a list of the support variables. This is used when checking constraint consistency: if no changes to variables that support a constraint have been made, the constraint does not need to be checked.

Before the implementation of MetaExpressions, the above constraint parsing would look at constraint (defined above) and rule that the implicit expression created by indexing exponentArray is the only variable that needs to be tracked. This is incorrect. The var_i variable needs to be tracked as well, which the introduction of MetaExpressions now does.