/* From PRACTICAL CONSTRAINTS: A TUTORIAL ON MODELLING WITH CONSTRAINTS ROMAN BARTÁK http://kti.mff.cuni.cz/~bartak/NASSLLI2003/files/paper4.pdf */ /* A Golomb ruler of size M is a ruler with M marks placed in such a way that the distances between the marks are different. The shortest ruler is optimal. An optimal Golomb ruler of size 5 is shown below 01 4 9 11 || | | | There is no known algorithm for finding a Golomb ruler of size M>=24. Design a constraint model to describe the problem of finding the optimal Golomb ruler. */ golomb(M,Sol):- Sol = [0|_], UpperBound is M*M, ruler(M,-1,UpperBound,Sol), last(Sol,XM), distances(Sol,1,M,XM,Dist), all_distinct(Dist), (Dist=[DF,_|_] -> last(Dist,DL), DF#