Here is a small model that I have. I'm trying to solve it with Chuffed. There are a lot more constraints and variables to my problem, but I tried to single out what is not working.
% Model parameters.
int: n_steps; % Number of steps in the scheduling horizon
enum tasks; % Set of all task ids
enum work_centers; % Set of all work center ids
% task_work_center[t] is the work center required to do task t
array [tasks] of work_centers: task_work_center;
% Model variables.
% task_start[t] is the starting step of task t
array [tasks] of var 1..n_steps: task_start ::add_to_output;
% Constraints.
% Example : array[1..n] of set of int: x = [ {k | k in sum([s[j] | j in 1..i-1])+1..sum([s[j] | j in 1..i]) } | i in 1..n];
array[work_centers] of var set of 1..n_steps: work_center_tasks = [{task_start[t] | t in tasks where task_work_center[t]==wc} | wc in work_centers];
array[work_centers] of var int: task_permutation;
include "arg_sort.mzn";
constraint
forall(wc in work_centers)(
task_permutation[wc] = arg_sort(work_center_tasks[wc]) %%% Does NOT work !!!
);
% Objective.
solve satisfy;
I get the following error :
MiniZinc: type error: no function or predicate with this signature found: `arg_sort(var set of int)' Cannot use the following functions or predicates with the same identifier: function array [int] of $$E : arg_sort(array [$$E] of $$T: x); (argument 1 expects type array[int] of int, but type var set of int given) function array [int] of var $$E : arg_sort(array [$$E] of var $$T: x); (argument 1 expects type array[int] of var int, but type var set of int given) function array [int] of $$E : arg_sort(array [$$E] of float: x); (argument 1 expects type array[int] of float, but type var set of int given) function array [int] of var $$E : arg_sort(array [$$E] of var float: x); (argument 1 expects type array[int] of var float, but type var set of int given) predicate arg_sort(array [$$E] of var $$T: x,array [int] of var $$E: p); (requires 2 arguments, but 1 given) predicate arg_sort(array [$$E] of var float: x,array [int] of var $$E: p); (requires 2 arguments, but 1 given)
Do you guys know of a way to do this ? It seems like arg_sort cannot be used on var set of int... I don't mind using another method.
Edit/Adding information : I actually know in advance the dimensions of work_center_tasks, but it varies from one work center to another. If I can model that without using sets, that would work too !
Here is a small model that I have. I'm trying to solve it with Chuffed. There are a lot more constraints and variables to my problem, but I tried to single out what is not working.
% Model parameters.
int: n_steps; % Number of steps in the scheduling horizon
enum tasks; % Set of all task ids
enum work_centers; % Set of all work center ids
% task_work_center[t] is the work center required to do task t
array [tasks] of work_centers: task_work_center;
% Model variables.
% task_start[t] is the starting step of task t
array [tasks] of var 1..n_steps: task_start ::add_to_output;
% Constraints.
% Example : array[1..n] of set of int: x = [ {k | k in sum([s[j] | j in 1..i-1])+1..sum([s[j] | j in 1..i]) } | i in 1..n];
array[work_centers] of var set of 1..n_steps: work_center_tasks = [{task_start[t] | t in tasks where task_work_center[t]==wc} | wc in work_centers];
array[work_centers] of var int: task_permutation;
include "arg_sort.mzn";
constraint
forall(wc in work_centers)(
task_permutation[wc] = arg_sort(work_center_tasks[wc]) %%% Does NOT work !!!
);
% Objective.
solve satisfy;
I get the following error :
MiniZinc: type error: no function or predicate with this signature found: `arg_sort(var set of int)' Cannot use the following functions or predicates with the same identifier: function array [int] of $$E : arg_sort(array [$$E] of $$T: x); (argument 1 expects type array[int] of int, but type var set of int given) function array [int] of var $$E : arg_sort(array [$$E] of var $$T: x); (argument 1 expects type array[int] of var int, but type var set of int given) function array [int] of $$E : arg_sort(array [$$E] of float: x); (argument 1 expects type array[int] of float, but type var set of int given) function array [int] of var $$E : arg_sort(array [$$E] of var float: x); (argument 1 expects type array[int] of var float, but type var set of int given) predicate arg_sort(array [$$E] of var $$T: x,array [int] of var $$E: p); (requires 2 arguments, but 1 given) predicate arg_sort(array [$$E] of var float: x,array [int] of var $$E: p); (requires 2 arguments, but 1 given)
Do you guys know of a way to do this ? It seems like arg_sort cannot be used on var set of int... I don't mind using another method.
Edit/Adding information : I actually know in advance the dimensions of work_center_tasks, but it varies from one work center to another. If I can model that without using sets, that would work too !
Share Improve this question edited yesterday Emilie Picard-Cantin asked yesterday Emilie Picard-CantinEmilie Picard-Cantin 2903 silver badges15 bronze badges 1 |1 Answer
Reset to default 0Yes, it seems that fzn_arg_sort_set.mzn is not defined in minizinc standard library.
arg_sort(work_center_tasks[wc])
to do. It seems you are trying to callarg_sort
on avar set of int
, which doesn't seem to make sense because the element of the set are unordered, and it is defined that iterating over the set will always be ordered in MiniZinc. – Dekker1 Commented 9 hours ago