libminizinc
libminizinc copied to clipboard
Unintuitive result of arg_max with generator call expression
Consider:
array[1..9] of int: arr = [10, 20, 30, 40, 50, 60, 70, 80, 90];
Then arg_max(arr)
equals 9, which makes sense.
However, arg_max(i in 6..8)(arr[i])
equals 3, which is unintuitive to me. The expected result is 8. Technically, 3 is correct, because the specification states this is equivalent to arg_max([arr[i] | i in 6..8])
, without an index set.
Is it possible to copy the index set in this case, so that it is equivalent to arg_max(array1d(6..8, [arr[i] | i in 6..8]))
instead?
If you use an array slice, then the index set will be preserved
arg_max(arr[6..8])
Thanks, that works.
Still, I would like to propose arg_max(i in 6..8)(arr[i])
to also be 8, or perhaps to give a warning.