Conversation
|
We could also replace public static Tuples scalar(IntVar[] VARS, final int[] COEFFS, IntVar SCALAR, final int SCALAR_COEFF) { |
| */ | ||
| public static Tuples eucl_div(IntVar DIVIDEND, IntVar DIVISOR, IntVar RESULT) { | ||
| return generateTuples(values -> values[0] / values[1] == values[2], true, DIVIDEND, DIVISOR, RESULT); | ||
| public static Tuples eucl_div(IntVar result, IntVar dividend, IntVar divisor) { |
There was a problem hiding this comment.
It is a little bit dangerous to change the order of the parameters, isn't it ?
There was a problem hiding this comment.
Good remark. The problem is that the result is currently not always in the same position (last argument for modulo, div and times but first position for square) so we would need to make some change anyway if we want to have a clear convention (either all first or all last). I chose the result position at first to allow an IntVar... signature for the other variables (in generateTuplesWithResult and canBeTupledWithResult) :
if (TuplesFactory.canBeTupledWithResult(result, base)) {
return table(new IntVar[]{result, base}, TuplesFactory.square(result, base));
}
but we may prefer using an explicit array IntVar[] in which case both positions would be fine (yet a convention either first or last would help avoiding errors).
Maybe we could simply rename TuplesFactory to make sure the code is reviewed upon solver update ?
We can also keep existing signatures and be cautious when calling generateTuplesWithResult.
Let me know what you prefer or if you have other suggestions
No description provided.