chocoteam / choco-solver

An open-source Java library for Constraint Programming
http://choco-solver.org/
BSD 4-Clause "Original" or "Old" License
690 stars 143 forks source link

Fix bug in removeAllValuesBut and removeValues and for enumerated domain variables #1011

Closed cprudhom closed 1 year ago

cprudhom commented 1 year ago

I had this pernicious bug that occurs when the removeAllValuesBut method is called from for enumerated domain variables. This occurs when the variable is also monitored (here, a task) : the bounds was not up to date. Which led to inconcistency. To fix the bug, I encapsulate the internal updateBounds call in a loop to make sure that side effects (monitors or views) are capture at the right time. I also fix a bug in removeValues.

cprudhom commented 1 year ago

Now that I look back to the code, I think there is a better alternative to while-loops. I will suggest another correction soon

cprudhom commented 1 year ago

Now that I look back to the code, I think there is a better alternative to while-loops. I will suggest another correction soon

I finally let the code as is, I don't want the code to introduce to much code

cprudhom commented 1 year ago

What the v and the c stand for in vlb/vub and clb/cub ? Otherwise, seems fine to me !

I am not very inspired: v stands for values, name of the parameter in the API, and c stands for current.