Optimizing Integer-Constrained Circle Packing using Differential Evolution in Python.
dev.to·6d·
Discuss: DEV
🧬Optimization Algorithms
Preview
Report Post

Introduction: The "Brute Force" Trap

I’ll be honest: I thought this would be easy. My goal was simple: fit as many non-overlapping circles as possible into a 100x100 pixel grid.

My first instinct was to use a standard Brute Force approach. I wrote a script to randomly guess x, y coordinates and radii. I let it run for hours. The result? A mess. The circles either overlapped constantly or left huge, inefficient gaps. The problem wasn’t the geometry; it was the grid.

Unlike pure math, where a circle can be at position 10.5553, my system was constrained to an Integer Grid (pixels). This seemingly small constraint broke standard geometric formulas. The "perfect" mathematical position was often "illegal" in my pixel grid.

I realized I didn’t need a calculator; I need…

Similar Posts

Loading similar posts...