Distribution of 10 points within a unit square

8

1

Related to some packing problems, following problem arose:

Distribute 10 points within a square of sides 1, so that minimal distance between them is maximized.

With the help of random simulation, or any other method, please provide example of such distribution, with graphical representation of square and points, and value of minimal distance between points for such distribution.

The answer with distribution with largest minimal distance wins the "answer badge"! :)

(This problem so far to my knowledge couldn't be solved by pure mathematics, so I am coming here for valuable and desperately needed help regarding simulations etc.)

VividD

Posted 2014-05-11T09:16:59.163

Reputation: 3 500

3You could use NMaximize. – b.gates.you.know.what – 2014-05-11T09:37:21.207

1

Possibly related: (2594)

– Mr.Wizard – 2014-05-11T12:26:16.330

Answers

13

Since this does seem to be a kind of packing problem I searched for prior explorations, and found a list of packings for equal-circles within a square at:

The best known packing for N = 10 is shown as:

enter image description here

The coordinates for the points are:

   1  -0.055497063038156969690135505676  -0.351795677434771201331992637257
   2   0.240911582092300627645879219810  -0.351795677434771201331992637257
   3  -0.351795677434771201331992637257  -0.343720034134076580133895794673
   4   0.055387032304313603995977911771  -0.076908787408790806346486820340
   5   0.351795677434771201331992637257  -0.076908787408790806346486820339
   6  -0.351795677434771201331992637257  -0.047311389003618982797881069187
   7  -0.132623434010086730621834242216   0.152242144215576109267055784036
   8   0.351795677434771201331992637257   0.219499857721666790989527905147
   9  -0.351795677434771201331992637257   0.351795677434771201331992637257
  10   0.086548809414597740088324152827   0.351795677434771201331992637257

Plotted:

pts = {{-0.0554971`, -0.351796`}, {0.240912`, -0.351796`}, {-0.351796`, -0.34372`},
 {0.055387`, -0.0769088`}, {0.351796`, -0.0769088`}, {-0.351796`, -0.0473114`},
 {-0.132623`, 0.152242`}, {0.351796`, 0.2195`}, {-0.351796`, 0.351796`},
 {0.0865488`, 0.351796`}};

m = Min @ pts;

Graphics[{
  {LightBlue, Rectangle[{m, m}, -{m, m}]},
  {Red, AbsolutePointSize[15], Point @ pts}
}]

enter image description here

The minimal distance between points (full precision, and scaled to a unit square) is: 0.42127954398...

I suspect a better solution will not be forthcoming.


Old comments

Blatantly copying Simon's code, but messing with optimization parameters I get this:

pts = Array[{x[#], y[#]} &, 10];
mindist2 = Min[#.# & /@ Subtract @@@ Subsets[pts, {2}]];
vars = Flatten[pts];
constraints = Thread[0 <= vars <= 1];
{md2, rules} = 
  NMaximize[{mindist2, constraints}, vars, 
   Method -> {"DifferentialEvolution",
              "CrossProbability" -> 0.6,
              "ScalingFactor" -> 0.68,
              "RandomSeed" -> 42}];

minimaldistance = Sqrt[md2]

Graphics[{Yellow, Rectangle[], Red, PointSize[Large], Point[pts /. rules]}]
0.417788

enter image description here

This is a better result, but I have zero confidence that it is optimal. I wonder how else one might approach this.

Mr.Wizard

Posted 2014-05-11T09:16:59.163

Reputation: 259 163

18

A simple numerical maximization using NMaximize as suggested by b.gatessucks:

pts = Array[{x[#], y[#]} &, 10];
mindist2 = Min[#.# & /@ Subtract @@@ Subsets[pts, {2}]];
vars = Flatten[pts];
constraints = Thread[0 <= vars <= 1];
{md2, rules} = NMaximize[{mindist2, constraints}, vars];

minimaldistance = Sqrt[md2]
(* 0.381759 *)

Graphics[{Yellow, Rectangle[], Red, PointSize[Large], Point[pts /. rules]}]

enter image description here

Update

Rahul Narain's comment informs us that to maximize $\min(f_1,...,f_n)$ it is typically more efficient to introduce a new variable $t$ and maximize that with the constraints $t\le f_1,...,t\le f_n$. Modifying the code to work that way, and blatantly copying Mr. Wizard's method optimizations gives an improved result:

pts = Array[{x[#], y[#]} &, 10];
dist2 = #.# & /@ Subtract @@@ Subsets[pts, {2}];
vars = Flatten[pts];
constraints = Thread[0 <= vars <= 1] ~Join~ Thread[mindist < dist2];
{md2, rules} = NMaximize[{mindist, constraints}, Append[vars, mindist], 
  Method -> {"DifferentialEvolution", "CrossProbability" -> 0.6, 
    "ScalingFactor" -> 0.68, "RandomSeed" -> 42}];

minimaldistance = Sqrt[md2]
(* 0.421268 *)

enter image description here

Simon Woods

Posted 2014-05-11T09:16:59.163

Reputation: 81 905

3Typically in optimization, if you want to maximize $\min(f_1,\ldots,f_n)$ it is more efficient to maximize a new variable $t$ subject to the constraints $t\le f_1, \ldots, t\le f_n$. – None – 2014-05-11T17:19:40.907

So, it looks NMaximize returned some kind of local maximum 0.38 (the other answer has 0.42)! – VividD – 2014-05-11T17:38:14.013

Just to put my money where my mouth is, simply doing NMaximize[{t, Join[Thread[t <= List @@ mindist2], constraints]}, Append[vars, t]] without any messing with optimization parameters gives a minimal distance of $0.419542$. – None – 2014-05-11T18:25:06.703

@RahulNarain, thanks! I've just added your solution to my post. – Simon Woods – 2014-05-11T18:27:24.720

1I guess we did it simultaneously. :) It's gratifying that your new solution seems to be the same as the best known packing posted by Mr.Wizard under a reflection across the NE/SW diagonal. – None – 2014-05-11T18:33:58.680

FYI: my "method optimizations" were random values that seemed to work OK, not something special. Changing those values acted like a chaos system which is why I went searching for something else. – Mr.Wizard – 2014-05-11T18:51:00.893

3Also FYI: using the numbers referenced in my answer I believe the optimal (known) spacing is: 0.4212795 -- I wonder if that can be coaxed out of Mathematica? – Mr.Wizard – 2014-05-11T18:58:03.340

@Mr.Wizard, perhaps with sufficient runs with different random seeds! Otherwise it probably needs someone who really understands numerical optimization. Personally I just treat NMaximize as a black box full of magic. – Simon Woods – 2014-05-11T19:50:56.807

4@Mr.Wizard, Simon: Try setting MaxIterations -> 200 and no other parameters. I get a minimum distance of 0.4212794349471961. – None – 2014-05-11T21:10:29.717

@Rahul Thanks, that's what I was looking for. – Mr.Wizard – 2014-05-11T23:42:42.900