lifebeyondfife / Decider

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

Prune value from Variable, not Domain. #27

Closed lifebeyondfife closed 4 years ago

lifebeyondfife commented 4 years ago

In order to save expensive domain copy operations, Decider only copies the domain of a variable if the variable is instantiated or inference (propagation) alters the domain. A stack maintains the domain copies, each with the depth in the search tree where the modification took place.

A bug was introduced during the creation of the ConstrainedArray type. When it performed domaining pruning, it went straight to the most recent domain and removed values. This had the effect that search inference performed deep in the tree, appeared to take place nearer the root than it did.

This fix ensures that the Variable class prunes the domain values because it will create a copy of the domain for the stack if necessary.