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