# Encoding golomb-ruler_optimization.gringo

Name golomb-ruler_optimization.gringo [Root]    Unclassified (114) Martin Gebser Martin Gebser and Roland Kaminski A Gringo encoding of Golomb Ruler. 2009-04-01 18:22 2009-06-05 13:48 Golomb Ruler lengthNeeded/1mark/1position/1 lengthNeeded/1location/2mark/1position/1 No ASP Contest 09 (Martin Gebser) #hide dist/2. #hide free/1. #hide full/1. location(1,0) :- mark(1), position(0). 1 { location(M,P) : position(P) : P > 0 } 1 :- mark(M), M > 1. { location(M,P) : mark(M) : M > 1 } 1 :- position(P), P > 0. % replace upper with below one if marks should be in order % :- location(M1,P1), location(M2,P2), M1 < M2, P1 >= P2. dist(M1,P2-P1) :- location(M1,P1), full(P2), P1 < P2. % replace upper with below one if marks should be in order % dist(M1,P2-P1) :- location(M1,P1), location(M2,P2), M1 < M2, P1 < P2. :- dist(M1,D), dist(M2,D), M1 < M2. :- lengthNeeded(D), not dist(M,D) : mark(M). full(P) :- location(M,P). free(P) :- position(P), not full(P), free(Q) : position(Q) : Q > P. #maximize { free(P) : position(P) }. % can replace upper three with below one if marks should be in order % #minimize [ location(M,P) : mark(M) : not mark(M+1) : position(P) = P ].