% % Linkage Analysis Problem in Weighted CSP wcsp format reader for MiniZinc % % Usage: awk -f linkage2dzn.awk pedigree1.wcsp 1000000 1 > pedigree1.dzn % minizinc linkage.mzn pedigree1.dzn % % % This MiniZinc model was created by Simon de Givry, degivry@toulouse.inra.fr % include "globals.mzn"; int: num_variables; % domains int:max_domain; array[1..num_variables] of int: domains; % cost functions in extension int: top; int: cost0; int: num_constraints1; int: max_constraints1; int: max_costs1; int: num_constraints2; int: max_constraints2; int: max_costs2; int: num_constraints3; int: max_constraints3; int: max_costs3; int: num_constraints33; int: max_constraints33; int: num_constraints4; int: max_constraints4; int: num_constraints5; int: max_constraints5; int: max_costs5; array[1..num_constraints1] of int: func1x; array[1..num_constraints1] of int: num_tuples1; array[1..num_constraints1] of int: cum_tuples1; array[1..max_constraints1] of int: costs1; array[1..num_constraints2] of int: func2x; array[1..num_constraints2] of int: func2y; array[1..num_constraints2] of int: num_tuples2; array[1..num_constraints2] of int: cum_tuples2; array[1..max_constraints2] of int: costs2; array[1..num_constraints3] of int: func3x; array[1..num_constraints3] of int: func3y; array[1..num_constraints3] of int: func3z; array[1..num_constraints3] of int: num_tuples3; array[1..num_constraints3] of int: cum_tuples3; array[1..max_constraints3] of int: costs3; array[1..num_constraints33] of int: func33x; array[1..num_constraints33] of int: func33y; array[1..num_constraints33] of int: func33z; array[1..num_constraints33] of int: num_tuples33; array[1..num_constraints33] of int: cum_tuples33; array[1..max_constraints33] of int: constraints33; array[1..num_constraints4] of int: func4x; array[1..num_constraints4] of int: func4y; array[1..num_constraints4] of int: func4z; array[1..num_constraints4] of int: func4v; array[1..num_constraints4] of int: num_tuples4; array[1..num_constraints4] of int: cum_tuples4; array[1..max_constraints4] of int: constraints4; array[1..num_constraints5] of int: func5x; array[1..num_constraints5] of int: func5y; array[1..num_constraints5] of int: func5z; array[1..num_constraints5] of int: func5v; array[1..num_constraints5] of int: func5w; array[1..num_constraints5] of int: num_tuples5; array[1..num_constraints5] of int: cum_tuples5; array[1..max_constraints5] of int: costs5; % the assignments array[1..num_variables] of var 0..max_domain: p; % objective function costs array[1..num_constraints1] of var 0..max_costs1: ocosts1; array[1..num_constraints2] of var 0..max_costs2: ocosts2; array[1..num_constraints3] of var 0..max_costs3: ocosts3; array[1..num_constraints5] of var 0..max_costs5: ocosts5; var 0..(top-1): objective; % solve minimize objective; solve :: int_search(p, first_fail, indomain_min, complete) minimize objective; constraint objective = cost0 + sum(j in 1..num_constraints1) ( ocosts1[j] ) + sum(j in 1..num_constraints2) ( ocosts2[j] ) + sum(j in 1..num_constraints3) ( ocosts3[j] ) + sum(j in 1..num_constraints5) ( ocosts5[j] ) /\ % ensure that each variable takes a value in its domain forall(j in 1..num_variables) ( p[j] < domains[j] ) /\ % unary cost functions forall(j in 1..num_constraints1) ( table([ocosts1[j],p[func1x[j]]], array2d(1..num_tuples1[j],1..2,[costs1[u] | u in (2*cum_tuples1[j]+1)..(2*cum_tuples1[j]+num_tuples1[j]*2)])) ) /\ % binary cost functions forall(j in 1..num_constraints2) ( table([ocosts2[j],p[func2x[j]],p[func2y[j]]], array2d(1..num_tuples2[j],1..3,[costs2[u] | u in (3*cum_tuples2[j]+1)..(3*cum_tuples2[j]+num_tuples2[j]*3)])) ) /\ % ternary cost functions forall(j in 1..num_constraints3) ( table([ocosts3[j],p[func3x[j]],p[func3y[j]],p[func3z[j]]], array2d(1..num_tuples3[j],1..4,[costs3[u] | u in (4*cum_tuples3[j]+1)..(4*cum_tuples3[j]+num_tuples3[j]*4)])) ) /\ % hard ternary constraints forall(j in 1..num_constraints33) ( table([p[func33x[j]],p[func33y[j]],p[func33z[j]]], array2d(1..num_tuples33[j],1..3,[constraints33[u] | u in (3*cum_tuples33[j]+1)..(3*cum_tuples33[j]+num_tuples33[j]*3)])) ) /\ % hard 4-arity constraints forall(j in 1..num_constraints4) ( table([p[func4x[j]],p[func4y[j]],p[func4z[j]],p[func4v[j]]], array2d(1..num_tuples4[j],1..4,[constraints4[u] | u in (4*cum_tuples4[j]+1)..(4*cum_tuples4[j]+num_tuples4[j]*4)])) ) /\ % 5-arity cost functions forall(j in 1..num_constraints5) ( table([ocosts5[j],p[func5x[j]],p[func5y[j]],p[func5z[j]],p[func5v[j]],p[func5w[j]]], array2d(1..num_tuples5[j],1..6,[costs5[u] | u in (6*cum_tuples5[j]+1)..(6*cum_tuples5[j]+num_tuples5[j]*6)])) ) % % solution checker for pedigree1.dzn: objective=757 % /\ % forall(j in 1..798) ( % 334) ( % p[j] = [0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,1,1,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,1,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,1,1,1,2,2,1,1,2,1,1,3,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,0,0,2,2,1,1,1,1,1,1,2,0,0,1,1,0,0,1,1,0,0,1,1,1,0,0,1,0,0,3,1,1,0,0,1,1,1,1,1,0,1,0,1,1,1,2,1,0,1,1,1,1,1,0,1,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0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