this repo has no description
1include "arg_max_int.mzn";
2include "arg_max_bool.mzn";
3include "arg_max_float.mzn";
4
5/** @group globals
6 Returns the index of the maximum value in the array \a x.
7 When breaking ties the least index is returned.
8*/
9function var $$E: arg_max(array[$$E] of var int: x) =
10 let { constraint length(x) > 0; } in arg_max_total(x);
11
12/** @group globals
13 Returns the index of the maximum value in the array \a x.
14 When breaking ties the least index is returned.
15*/
16function var $$E: arg_max(array[$$E] of var bool: x) =
17 let { constraint length(x) > 0; } in arg_max_total(x);
18
19/** @group globals
20 Returns the index of the maximum value in the array \a x.
21 When breaking ties the least index is returned.
22*/
23function var $$E: arg_max(array[$$E] of var float: x) =
24 let { constraint length(x) > 0; } in arg_max_total(x);
25
26function var $$E: arg_max_total(array[$$E] of var int: x) :: promise_total =
27 if length(x) = 0 then 0 else
28 let { var min(index_set(x)) .. max(index_set(x)): i;
29 constraint maximum_arg_int(x, i); }
30 in i endif;
31function var $$E: arg_max_total(array[$$E] of var bool: x) :: promise_total =
32 if length(x) = 0 then 0 else
33 let { var min(index_set(x)) .. max(index_set(x)): i;
34 constraint maximum_arg_bool(x, i); }
35 in i endif;
36function var $$E: arg_max_total(array[$$E] of var float: x) :: promise_total =
37 if length(x) = 0 then 0 else
38 let { var min(index_set(x)) .. max(index_set(x)): i;
39 constraint maximum_arg_float(x, i); }
40 in i endif;
41
42/** @group globals
43 Constrain \a i to be the index of the maximum value in the array \a x.
44 When breaking ties the least index is returned.
45
46 Assumption: |\a x| > 0
47*/
48predicate maximum_arg(array[int] of var int: x, var int: i) =
49 maximum_arg_int(x, i);
50
51/** @group globals
52 Constrain \a i to be the index of the maximum value in the array \a x.
53 When breaking ties the least index is returned.
54
55 Assumption: |\a x| > 0
56*/
57predicate maximum_arg(array[int] of var bool: x, var int: i) =
58 maximum_arg_bool(x, i);
59
60/** @group globals
61 Constrain \a i to be the index of the maximum value in the array \a x.
62 When breaking ties the least index is returned.
63
64 Assumption: |\a x| > 0
65*/
66predicate maximum_arg(array[int] of var float: x, var int: i) =
67 maximum_arg_float(x, i);