-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce new propagator for nValues constraint based on witness/watch #674
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update CHANGES.md ?
private IntVar nValue; | ||
private final int n; | ||
private int[] concernedValues; | ||
private IStateInt[] witness; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for witnesses (or watch literal) to be backtrackable.
Indeed, if a value was considered as watched at a given time, it remains true on backtrack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I should use int[] instead of IStateInt[]
super(ArrayUtils.concat(vars, nvalue), PropagatorPriority.LINEAR, true); | ||
this.nValue = nvalue; | ||
n = vars.length; | ||
TIntArrayList list = new TIntArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using a TIntHashSet
instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there is no method sort() on a TIntHashSet, and I think there might be code optimisation to do if the values are sorted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why to you the values in concernedValues
to be sorted ?
Alternatively, you could sort concernedValues
in place using Arrays.sort
.
solver/src/main/java/org/chocosolver/solver/constraints/nary/nvalue/PropNValue.java
Show resolved
Hide resolved
concernedValues = list.toArray(); | ||
possibleValues = SetFactory.makeStoredSet(SetType.BITSET, 0, model); | ||
mandatoryValues = SetFactory.makeStoredSet(SetType.BITSET, 0, model); | ||
witness = new IStateInt[concernedValues.length]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be initialized with
witness = new int[concernedValues.length];
Arrays.fill(witness, -1);
Codecov Report
@@ Coverage Diff @@
## master #674 +/- ##
============================================
- Coverage 41.51% 23.9% -17.61%
+ Complexity 6674 3975 -2699
============================================
Files 634 635 +1
Lines 40255 40343 +88
Branches 7685 7710 +25
============================================
- Hits 16711 9645 -7066
- Misses 21875 29623 +7748
+ Partials 1669 1075 -594
Continue to review full report at Codecov.
|
super(ArrayUtils.concat(vars, nvalue), PropagatorPriority.LINEAR, true); | ||
this.nValue = nvalue; | ||
n = vars.length; | ||
TIntArrayList list = new TIntArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why to you the values in concernedValues
to be sorted ?
Alternatively, you could sort concernedValues
in place using Arrays.sort
.
Changes proposed in this PR:
@chocoteam/core-developer