Stop maintaining the domain size for IntervalIntVarImpl. #1050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For such variables, the solver used to track the lower-bound, the upper-bound and the domain size to provide quick access to the domain size. This decision had however a significant impact in terms of memory usage. It requires to have an additional StoredInt per variable and for every bound change, 2 values where saved into the stack.
In this patch, the domain size is no longer stored but computed on demand. In terms of performance, getDomainSize() performs now 2 get() and one subtraction while it used to perform one get(). On the other side it saves one StoredInt, and only one value is saved into the stack when a bound is updated.
After some internal experiments on (packing and scheduling) problems having around 100,000 bounded variables and 50,000 enum variables, this reduces the memory consumption of my JVM by about 30% with no performance degradation.