Application Center - Maplesoft

App Preview:

Packing Disks into a Circle

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application




Packing Disks into a Circle

Introduction

This application finds the best packing of unequal non-overlapping disks in a larger circle, such that the radius of the container is minimized. This is a difficult global optimization problem that demands strong solvers; this application uses Maple's Global Optimization Toolbox. You must have the Global Optimization Toolbox installed to use this application

 

One solution for the packing of 50 disks with the radii 1 to 50 (as found by this application) is visualized below. Other solutions are documented at http://www.packomania.com.

 

 

Packing optimization is industrially important, with applications in pallet loading, the arrangement of fiber optic cables in a tube, or the placing of blocks on a circuit board.

Setup

restart
with(GlobalOptimization)

Number of circles

n := 50

Radius of circle n is equal to n

for i to n do r[i] := i end do

Decision Variables and Optimization Bounds

The decision variables are the coordinates (x__i, y__i) of the centers of the circles, and the radius rc of the circumscribing circle.

vars := [seq(x[i], i = 1 .. n), seq(y[i], i = 1 .. n), rc]

bounds := seq(vars[i] = -500 .. 500, i = 1 .. 2*n), rc = 0 .. 500

Constraints

d__i is the maximum distance from the origin to a point on the circumference of circle i

for i to n do d[i] := r[i]+sqrt(x[i]^2+y[i]^2) end do

`dist__i,j` is the distance between the centers of any two circles minus their radii

for i to n-1 do for j from i+1 to n do dist[i, j] := sqrt((x[i]-x[j])^2+(y[i]-y[j])^2)-r[i]-r[j] end do end do

The maximum distance between the furthest point on a circle's circumference and the origin must be smaller than the radius of the circumscribing circle.

cons1 := seq(d[i] <= rc, i = 1 .. n)

For circles i and j not to overlap, `dist__i,j` must be equal to or greater than zero.

cons2 := seq(seq(dist[i, j] >= 0, j = i+1 .. n), i = 1 .. n-1)

Hence the entire set of constraints

cons := {cons1, cons2}

Optimization and Results

soln := GlobalSolve(rc, cons, bounds, timelimit = 120, populationsize = 1000)

Hence the optimized radius of the circumscribing circle is

soln[1]

232.902317791590264

(5.1)

colorSpread := ColorTools:-EvenSpread("SteelBlue", n)

circs := seq(plottools:-disk([rhs(select(has, soln[2], x[i])[]), rhs(select(has, soln[2], y[i])[])], r[i], color = colorSpread[i], thickness = 2), i = 1 .. n)

boundingCirc := plottools:-disk([0, 0], rhs(select(has, soln[2], rc)[]), color = black, thickness = 5, color = "LightGray")

plots:-display(circs, boundingCirc, scaling = constrained, axesfont = [Calibri])