MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
521 stars 81 forks source link

Not sure if this is yuck (20230623) or minizinc (2.8.2) #772

Closed dedmedved closed 11 months ago

dedmedved commented 11 months ago

Running village.mzn, village0.dzn, village.mzc 309msec

redefinitions:2.25-50: MiniZinc: type error: FlatZinc builtins are not allowed to have arguments of type array[$] of var opt top redefinitions:2.25-50: MiniZinc: type error: FlatZinc builtins are not allowed to have arguments of type array[$] of var opt top redefinitions:2.25-50: MiniZinc: type error: FlatZinc builtins are not allowed to have arguments of type array[$] of var opt top redefinitions:2.25-50: MiniZinc: type error: FlatZinc builtins are not allowed to have arguments of type array[$] of var opt top fzn_table_bool:1.54-80: MiniZinc: type error: Type array[int,int] of bool is not allowed in as a FlatZinc builtin argument, arrays must be one dimensional fzn_table_bool_reif:2.33-59: MiniZinc: type error: Type array[int,int] of bool is not allowed in as a FlatZinc builtin argument, arrays must be one dimensional fzn_regular:3.5-30: MiniZinc: type error: Type array[int,int] of int is not allowed in as a FlatZinc builtin argument, arrays must be one dimensional fzn_regular_reif:3.5-30: MiniZinc: type error: Type array[int,int] of int is not allowed in as a FlatZinc builtin argument, arrays must be one dimensional fzn_table_int:1.52-77: MiniZinc: type error: Type array[int,int] of int is not allowed in as a FlatZinc builtin argument, arrays must be one dimensional fzn_table_int_reif:2.32-57: MiniZinc: type error: Type array[int,int] of int is not allowed in as a FlatZinc builtin argument, arrays must be one dimensional Process finished with non-zero exit code 1. Finished in 309msec.

Model is below

% include "gecode.mzn"; include "disjunctive.mzn"; include "yuck.mzn"; % Warning the village int: n; % number of houses set of int: HOUSE = 1..n; array[HOUSE] of int: x; array[HOUSE] of int: y; int: limit; % max time allowed

int: m; % number of messengers set of int: MESSENGER = 1..m; array[MESSENGER] of var HOUSE: messenger; % who are the messengers % constraint strictly_increasing(messenger) ; % constraint strictly_increasing([next[i] | i in n+1 .. n+m ]) ;

% nodes % 1..N are villagers % n+1..n+m are end trip node set of int: NODE = 1..n+m; array[NODE] of var NODE: next; % next node visited after this one var 0..limit: endtime; % array[NODE] of var NODE: prev; % next node visited after this one % constraint inverse(prev,next);

include "all_different.mzn"; constraint all_different(next); constraint all_different(messenger); include "globals.mzn";

% % no self loops % constraint forall( i in NODE) ( next[i] != i); % % no simple loops in non-dummy nodes % constraint forall( i in NODE) ( next[i] != prev[i]);

% constraint forall( i in 1..m) ( next[n+i] in messenger); constraint forall( i in 1..m-1) ( next[n+i] = messenger[i+1]); constraint ( next[n+m] = messenger[1]);

% constraint forall( i in 1..m-1) ( next[n+i+1] = messenger[i]); % try to build a circuit % array[NODE] of var NODE: c_next = [ next[i] | i in HOUSE] ++ [ next[i+1] | i in n+1 .. n+m-1] ++ [next[n+1]] ; % next node visited after this one % array[NODE] of var NODE: c_prev = [ prev[i] | i in NODE] ; % next node visited after this one

constraint circuit(next); % solve ::seq_search([int_search(next, dom_w_deg, indomain_random, complete),int_search(messenger, input_order, indomain_min, complete)]) % solve ::int_search(next, dom_w_deg, indomain_min, complete) % ::restart_luby(250) % ::restart_constant(3000) % ::relax_and_reconstruct(next,87) solve minimize endtime; %satisfy;

% split houses into m sets so that i and next[i] are in the same set % array[NODE] of var NODE: circuit_set; array[NODE] of var NODE: circuit_set_m; % constraint forall(i in MESSENGER) (has_element(messenger[i],circuit_set)); % constraint forall( i in NODE where next[i] <= n) ( circuit_set[next[i]] = circuit_set[i]); % constraint forall( i in MESSENGER) ( circuit_set[next[n+i]] = messenger[i]); constraint forall( i in NODE where next[i] <= n) ( circuit_set_m[next[i]] = circuit_set_m[i]); constraint forall( i in MESSENGER) ( circuit_set_m[next[n+i]] = n+i); array[MESSENGER] of var int: costs; % the cost of each trip

% constraint forall ( i in MESSENGER ) (costs[i] = sum(l in cloop where circuit_set[l] = i ) ((abs(x[i] - x[cloop[i]]) + abs(y[i] - y[cloop[i]]) )) );

% output("perl grapher.pl "++ concat([format(messenger[i])++" " | i in MESSENGER ]) ++ " && graph.jpg \n");

% output("perl grapher.pl "++ concat([format(prev[i])++" " | i in NODE ]) ++ " && graph.jpg \n"); % output("perl grapher.pl "++ concat([format(c_prev[i])++" " | i in NODE ]) ++ " && graph.jpg\n");

% output("perl grapher.pl "++ concat([format(next[i])++" " | i in NODE ]) ++ " && graph.jpg \n"); output("perl grapher.pl "++ concat([format(cnext[i])++" " | i in NODE ]) ++ " && graph.jpg \n"); % output("(index_set(next))\n");

% output("(next)\n"); % output ("(circuit_set) \n"); % output ("(obj) \n"); output ("(endtime) \n");

% constraint forall (i in n+1..n+m) ( at_least(3, circuit_set_m, i));

array[NODE] of var NODE: cnext = [ if next[i] > n then i else next[i] endif | i in NODE] ; array[NODE] of var NODE: cloop = [ if cnext[i] = i then next[circuit_set_m[i]] else cnext[i] endif | i in NODE] ;

output("perl grapher.pl "++ concat([format(cloop[i]) ++ " " | i in HOUSE ]) ++ " && graph.jpg \n");

output ("(costs) \n"); constraint forall ( i in 1..m ) (costs[i] = sum(l in 1..n where circuit_set_m[l] = n+i ) ((abs(x[l] - x[cloop[l]]) + abs(y[l] - y[cloop[l]]) )) );

constraint endtime = max( i in MESSENGER) (costs[i] ) ;

Dekker1 commented 11 months ago

These problems will have to be fixed in Yuck's MiniZinc solver library.

It seems that Yuck's library relies on some features that are ambiguous or disallowed in FlatZinc. We recently added a check for them in the MiniZinc compiler. It seems to errors for Yuck fall into two areas: