Possibly Optimal Golomb Rulers Calculated for 160 to 40,000 Marks.

Tomas Rokicki (rokicki@gmail.com) and Gil Dogon (gil.dogon@mobileye.com)

A Golomb ruler is a set of nonnegative integer values (marks) that includes zero and whose pairwise differences are all unique. That is, for every pair of distinct numbers (a,b) in the set, there is no other pair (c,d) such that a-b=c-d (unless a=c and b=d). The values in the set are called "marks", like marks on a ruler. The length of the ruler is equal to the maximum value in the set.

Finding the shortest Golomb ruler with a given number of marks (n) may be a difficult task. Indeed, a massive distributed project is under way to prove that the known 28-mark ruler (with a length of 585) is the shortest possible; it has been running for nearly two years and is about 12% complete.

Finding good (near-optimal) Golomb rulers using normal search techniques is difficult; we are not aware of any effective approach at this point in time. But a little bit of mathematics originated by James Singer in 1938 (with some follow-up help from R. C. Bose and S. Chowla) gives construction techniques for rulers that appear to be optimal (and are guaranteed to be near-optimal). Indeed, with the exception of six small sizes, no better Golomb rulers have been found than those generated by these construction methods. All the computational effort expended over the past two decades to prove the optimality of rulers with 18 through 27 marks has supported the assertion that rulers generated by these 75-year-old ideas are the best we can do.

But we are not certain this will continue for the larger sizes.

James B. Shearer implemented the construction methods in a set of Fortran programs around 1986, and generated the best set of Golomb rulers through 160 marks possible with these methods; his information is published on IBM's research site. He also implemented a brute-force search program that verified or found the optimal ruler lengths through 16 marks.

We have reimplemented Singer, Bose, and Chowla's ideas and run their constructions on modern machines, extending the set of possibly optimal rulers up through 40,000 marks. This has required some new ideas and improvements to the existing algorithms, which we describe below.

We believe these rulers are probably optimal, and are offering a $250 reward if anyone can beat any of these ruler lengths (for 36 through 40,000 marks) using any technique.

Modular Rulers

Every proper subset of a Golomb ruler is also a Golomb ruler (but one with fewer marks). (If the zero value is omitted you can subtract the smallest value from each value in the set to obtain a valid ruler.) Also, every Golomb ruler can be "flipped"---take the maximum value in the set, and subtract from this every value in the set to generate a new set that measures the same distances.

All of the constructions we use generate "modular" rulers. A modular ruler is one such that the marks can be placed on the circumference of a circle (of a specific size, the modulus), and all the distances measured are unique. While a standard Golomb ruler measures n(n-1)/2 distinct distances, a modular ruler measures n(n-1) distinct distances. Every subset of a modular ruler is also a modular ruler (with the same modulus). Every modular ruler is also a Golomb ruler.

Thus, every ruler we claim to be optimal, actually satisfies more constraints than strictly required; in addition to satisfying the normal Golomb requirements, it also is a modular ruler. While any Golomb ruler is also a modular ruler if you make the modulus large enough, it turns out the modulus for our rulers is typically only a little more than the total length of the ruler itself.

A perfect Golomb ruler with n marks measures exactly the distances 1 through n(n-1)/2. This is only possible through 4 marks (can you prove it is not possible for 5 or more marks?) A perfect modular ruler with n marks measures exactly the distances 1 through n(n-1) (and it is easy to show that its modulus must be n(n-1)+1). The 1938 Singer construction, which generates most of the rulers we suggest are optimal, generates perfect modular rulers, every time (but only for a number of marks that is one more than a prime power). Not only that but it generates many, many different perfect modular rulers. For instance, the Singer construction generates the following perfect modular ruler with 12 marks (and with modulus 133):

0 1 12 14 22 29 54 60 63 90 110 129

Pick any number from 1 to 133, and you can find two values that differ by that number (modulo 133) from the above set. For instance, for a difference of 65, you can pick 90 and 22; (22-90) mod 133 is 65. The best length 11 ruler that we can extract from directly this ruler is of length 94 (from the 129 wrapping around to the 90). But we can generate a new modular ruler from this one by multiplying each value by 20 (which is relatively prime to 133) and sorting the result, giving us

0 3 14 16 20 41 48 53 63 71 72 107

From this modular Golomb ruler we can extract a length-11 Golomb ruler of length only 72 (from the 0 on the left to the 72 towards the end); this is one of only two optimal length-11 Golomb rulers.

The other two constructions we consider, the Bose-Chowla construction and the Ruzsa construction, generate near-optimal modular rulers.

The Methods

All the methods take a single input g, which is a prime power (or for Ruzsa's construction, just a prime) and require roughly the following steps:

PrimPoly: Find a primitive polynomial for a specific field generated by that prime. This provides a numbering of the elements of the field.

Select: From that field, select members that satisfy a specific criteria specific to the construction. This will generate the modular ruler.

Multiply: From the original modular ruler, generate a lot of additional modular rulers by multiplying that ruler by numbers relatively prime to the modulus.

Sort: Since the values of the multiplied modular ruler are not generated in numerical order, sort the modular ruler.

Scan: For each of these modular rulers, try all contiguous sub-rulers as candidate Golomb rulers.

The Fortran programs written by James B. Shearer include all of these steps in a clear and straightforward manner. In order to extend the results as far as we did, the algorithms for each step needed improvement.

There have been a number of papers written on finding primitive polynomials in Galois fields, and implementations of these ideas are available on the web. The ideas in these papers are nontrivial but critical in order to generate primitive polynomials of Galois fields with millions or billions of elements. Both of us independently authored primitive polynomial generation code.

The selection criteria for each of the distinct constructions is fairly non-trivial (especially for the Singer construction). One of us essentially copied Shearer's code into C for this; the other reimplemented everything from scratch. The performance of the Shearer code here was adequate for our purposes.

There were a number of improvements to the multiply step. Both the Singer and the Bose-Chowla construction generated O(g2) distinct modular rulers (where g is the prime power used for generation). Since we will be sorting and scanning for every multiplicand we consider, it is important to eliminate redundant multiplicands. All of the constructions exhibited symmetry based on a particular subgroup, so we were able to exclude 5/6ths of the multiplicands for the Singer construction and 3/4ths of the multiplicands for the Bose-Chowla construction. The Ruzsa construction required consideration of many fewer multicands (O(g)) so symmetry reduction was not needed here.

In addition, the actual multiply step itself could be slow, with a 64-bit multiply and remainder calculated for each value. We improved this by maintaining a cache of small multiples of the input ruler modulo the modulus. When evaluating a new modulus m, if that was small compared to the previous modulus considered, we would just add-and-test the relevant multiple from the cache. The compiler turned this into efficient SSE instructions.

Most of the time in our program was spent in the sort phase. We tried numerous variations of radix sort and finally adopted one that was able to sort more than 100 million elements per second.

In the scan phase, we want to consider every possible sub-ruler from the current modular ruler for every possible Golomb ruler length. A straightforward implementation (as Shearer used) would take time O(n2) for every modular ruler. We were able to improve this as follows. First, since optimal rulers with 27 marks and fewer are already known, we did not scan for shorter rulers; we started our set of scans at 27. (We only did this optimization for values of g of 1000 or more, so we could pick up the known values as well, all of which are generated with small values of g.) So let us say the shortest ruler found for 27 marks for the current modular ruler turned out to be 950. For each mark count, we decided we did not care about rulers of lengths greater than n2. Further, we have a lower bound on the lengths of a Golomb ruler (n2-2n1.5+sqrt(n)-2). When considering whether to scan at length 27+x, we would add our best at 27 (950) to the lower bound on the length of a ruler with x marks, and if that was greater than either (27+x)2 or our best found ruler at length 27+x, we would skip that scan since it could never improve or match our best. This simple idea let us skip almost all scans with little effort. For instance, for 14,533 marks, we considered 22,680,000 moduli. Without this optimization we would have had to do roughly 14,000 scans per moduli; with it, we ended up doing only an average of 14.7 scans per moduli, a reduction by nearly a factor of 1000.

Results

With these ideas we were able to complete the constructions for all prime powers less than 40,000 and find what are likely to be the shortest Golomb rulers possible for all sizes through 40,000.

The data is given by the following files. All files are packed in the zip format except the C++ source for getrules. All files have a two-digit suffix indicating the range of values included; thus, the file golomb-all-13 contains information on Golomb rulers for sizes 13000 through 13999. Files named golomb-all-## contain the metadata for the best rulers constructed, with space-separated fields containing in order the number of marks, the total length, the type of construction used (pp for projective plane, and ap for affine plane), the prime power used to construct the modular ruler, and the multiplier to apply to that modular ruler. Files named modrules-pp-## and modrules-ap-## contain the actual modular rulers calculated, one per line. The line starts with the prime power, followed by a colon, and then space-separated integers giving the size of the gaps between the rulers. There are also four files called rulers-all-## containing the best Golomb rulers themselves (for sizes 5 through 3999), one per line. The line starts with the number of marks, followed by a colon, followed by space-separated locations of the marks themselves.

In addition, a C++ program called getruler.cpp is supplied that can be used to extract the probably optimal Golomb ruler for any size, given the above data files (after unzipping). Compile this program and give the desired size on the command line.

Size Ruler Metadata Modular Rulers (pp) Modular Rulers (ap) Golomb Rulers
5-999 golomb-all-00 modrules-pp-00 modrules-ap-00 rulers-all-00
1000-1999 golomb-all-01 modrules-pp-01 modrules-ap-01 rulers-all-01
2000-2999 golomb-all-02 modrules-pp-02 modrules-ap-02 rulers-all-02
3000-3999 golomb-all-03 modrules-pp-03 modrules-ap-03 rulers-all-03
4000-4999 golomb-all-04 modrules-pp-04 modrules-ap-04
5000-5999 golomb-all-05 modrules-pp-05 modrules-ap-05
6000-6999 golomb-all-06 modrules-pp-06 modrules-ap-06
7000-7999 golomb-all-07 modrules-pp-07 modrules-ap-07
8000-8999 golomb-all-08 modrules-pp-08 modrules-ap-08
9000-9999 golomb-all-09 modrules-pp-09 modrules-ap-09
10000-10999 golomb-all-10 modrules-pp-10 modrules-ap-10
11000-11999 golomb-all-11 modrules-pp-11 modrules-ap-11
12000-12999 golomb-all-12 modrules-pp-12 modrules-ap-12
13000-13999 golomb-all-13 modrules-pp-13 modrules-ap-13
14000-14999 golomb-all-14 modrules-pp-14 modrules-ap-14
15000-15999 golomb-all-15 modrules-pp-15 modrules-ap-15
16000-16999 golomb-all-16 modrules-pp-16 modrules-ap-16
17000-17999 golomb-all-17 modrules-pp-17 modrules-ap-17
18000-18999 golomb-all-18 modrules-pp-18 modrules-ap-18
19000-19999 golomb-all-19 modrules-pp-19 modrules-ap-19
20000-20999 golomb-all-20 modrules-pp-20 modrules-ap-20
21000-21999 golomb-all-21 modrules-pp-21 modrules-ap-21
22000-22999 golomb-all-22 modrules-pp-22 modrules-ap-22
23000-23999 golomb-all-23 modrules-pp-23 modrules-ap-23
24000-24999 golomb-all-24 modrules-pp-24 modrules-ap-24
25000-25999 golomb-all-25 modrules-pp-25 modrules-ap-25
26000-26999 golomb-all-26 modrules-pp-26 modrules-ap-26
27000-27999 golomb-all-27 modrules-pp-27 modrules-ap-27
28000-28999 golomb-all-28 modrules-pp-28 modrules-ap-28
29000-29999 golomb-all-29 modrules-pp-29 modrules-ap-29
30000-30999 golomb-all-30 modrules-pp-30 modrules-ap-30
31000-31999 golomb-all-31 modrules-pp-31 modrules-ap-31
32000-32999 golomb-all-32 modrules-pp-32 modrules-ap-32
33000-33999 golomb-all-33 modrules-pp-33 modrules-ap-33
34000-34999 golomb-all-34 modrules-pp-34 modrules-ap-34
35000-35999 golomb-all-35 modrules-pp-35 modrules-ap-35
36000-36999 golomb-all-36 modrules-pp-36 modrules-ap-36
37000-37999 golomb-all-37 modrules-pp-37 modrules-ap-37
38000-38999 golomb-all-38 modrules-pp-38 modrules-ap-38
39000-39999 golomb-all-39 modrules-pp-39 modrules-ap-39
40000-40000 golomb-all-40 modrules-pp-40 modrules-ap-40

Al Zimmermann's Programming Contests

This work was inspired by the most recent of Al Zimmermann's programming contests. Thank you, Al!

See Part 2 here.

References

James Singer, A Theorem in Finite Projective Geometry and Some Applications to Number Theory

Konstantinos Drakakis, A Review of the Available Construction Methods for Golomb Rulers

James Shearer, Golomb Rulers

Apostolos Dimitromanolakis, Analysis of the Golomb Ruler and the Sidon Set Problems, and Determination of Large, Near-Optimal Golomb Rulers

OGR-28 Project Overview