Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.2 kB · 41 lines
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142% RUNS ON mzn20_fd% RUNS ON mzn-fzn_fd% RUNS ON mzn20_fd_linear% RUNS ON mzn20_mip%------------------------------------------------------------------------%% Golomb rulers% prob006 in csplib%------------------------------------------------------------------------%% From csplib:% A Golomb ruler may be defined as a set of m integers 0 = a_1 < a_2 <% ... < a_m such that the m(m-1)/2 differences a_j - a_i, 1 <= i < j% <= m are distinct. Such a ruler is said to contain m marks and is of% length a_m. The objective is to find optimal (minimum length) or% near optimal rulers.%% This is the "ternary constraints and an alldifferent" model%------------------------------------------------------------------------%include "globals.mzn";int: m = 4;int: n = m*m;array[1..m] of var 0..n: mark;array[int] of var 0..n: differences = [ mark[j] - mark[i] | i in 1..m, j in i+1..m];constraint mark[1] = 0;constraint forall ( i in 1..m-1 ) ( mark[i] < mark[i+1] );constraint alldifferent(differences); % Symmetry breakingconstraint differences[1] < differences[(m*(m-1)) div 2];solve :: int_search(mark, input_order, indomain, complete) minimize mark[m];output ["golomb ", show(mark), "\n"];