1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.

70 lines
2.5 KiB
MiniZinc

include "arg_min_int.mzn";
include "arg_min_bool.mzn";
include "arg_min_float.mzn";
/** @group globals
Returns the index of the minimum value in the array \a x.
When breaking ties the least index is returned.
*/
function var $$E: arg_min(array[$$E] of var int: x) =
let { constraint length(x) > 0; } in arg_min_total(x);
/** @group globals
Returns the index of the minimum value in the array \a x.
When breaking ties the least index is returned.
*/
function var $$E: arg_min(array[$$E] of var bool: x) =
let { constraint length(x) > 0; } in arg_min_total(x);
/** @group globals
Returns the index of the minimum value in the array \a x.
When breaking ties the least index is returned.
*/
function var $$E: arg_min(array[$$E] of var float: x) =
let { constraint length(x) > 0; } in arg_min_total(x);
function var $$E: arg_min_total(array[$$E] of var int: x) :: promise_total =
if length(x) = 0 then 0 else
let { var min(index_set(x)) .. max(index_set(x)): i;
constraint minimum_arg_int(x, i); }
in i endif;
function var $$E: arg_min_total(array[$$E] of var bool: x) :: promise_total =
if length(x) = 0 then 0 else
let { var min(index_set(x)) .. max(index_set(x)): i;
constraint minimum_arg_bool(x, i); }
in i endif;
function var $$E: arg_min_total(array[$$E] of var float: x) :: promise_total =
if length(x) = 0 then 0 else
let { var min(index_set(x)) .. max(index_set(x)): i;
constraint minimum_arg_float(x, i); }
in i endif;
/** @group globals
Constrain \a i to be the index of the minimum value in the array \a x.
When breaking ties the least index is returned.
Assumption: |\a x| > 0
*/
predicate minimum_arg(array[int] of var int: x, var int: i) =
minimum_arg_int(x, i);
/** @group globals
Constrain \a i to be the index of the minimum value in the array \a x.
When breaking ties the least index is returned.
Assumption: |\a x| > 0
*/
predicate minimum_arg(array[int] of var bool: x, var int: i) =
minimum_arg_bool(x, i);
/** @group globals
Constrain \a i to be the index of the minimum value in the array \a x.
When breaking ties the least index is returned.
Assumption: |\a x| > 0
*/
predicate minimum_arg(array[int] of var float: x, var int: i) =
minimum_arg_float(x, i);