Application Center - Maplesoft

App Preview:

Packing Discs 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

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(r[i]+sqrt(x[i]^2+y[i]^2) <= rc, i = 1 .. n)

For circles i and j not to overlap, distance between the centers of any two circles minus their radii must be greater than zero

cons2 := seq(seq(sqrt((x[i]-x[j])^2+(y[i]-y[j])^2)-r[i]-r[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)

Hence the optimized radius of the circumscribing circle is

soln[1]

232.866858569466700

colorSpread := ColorTools:-Gradient([221, 231, 240] .. [240, 231, 221], number = 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 = 0), i = 1 .. n)

boundingCirc := plottools:-disk([0, 0], rhs(select(has, soln[2], rc)[]), color = RGB(236/255, 240*(1/255), 241/255), thickness = 0)

plots:-display(circs, boundingCirc, scaling = constrained, size = [800, 800], axes = none)

``