Inspiration

When we first saw the challenge proposed by Mecalux, we thought that it was very interesting and that it had a great similarity to a problem we did in a Programming Subject at university. Because of that, we believed it was a great way to apply our knowledge built in class to a more complex real-life problem. Beyond a classic 2D Bin Packing problem, we saw a geometric and economic puzzle where the physical rules (uneven ceilings, columns, asymmetrical walls) clash with a deceptively complex non-linear objective function. We realized that optimizing space (Area) and cost (Price/Load) sometimes pull in opposite directions, so we wanted to create an algorithm that didn't just brute-force the problem, but "flowed" organically through the warehouse, maximizing the efficiency of every millimeter. That's how Baymaxxing was born: maximizing bays with algorithmic precision.

What it does

We have designed a complex algorithm that uses a greedy and an aggressive automatized heuristic to minimize the objective function given by the company. In detail, we have focused on acquiring the most storage capacity, with the least cost possible. Baymaxxing ingests the warehouse topology (perimeter, obstacles, and ceiling) alongside the bay catalog to output this optimized configuration. With this objective in mind, the algorithm uses Organic Aisle Alignment to exploit gap superposition, as well as generating dense macro-blocks of bays placed “face-to-face” or “back-to-back”.

How we built it

Our program is built in Python and is based on 3 major points:

  • Computational Geometry: We have used the Shapely library to shape the warehouse, obstacles, and bays as exact mathematical models. With this, we could make precise collision validations and allow continuous rotations.
  • Active Node Packing: Instead of scanning a static grid, we implemented a priority queue. Whenever a bay is successfully placed, its vertices become "gravity nodes" that attract the next bay, achieving a pixel-perfect packing.
  • Parallel Swarm Exploration: Using the multiprocessing library, we launch multiple simultaneous explorers. Each one attacks the warehouse from a different gravitational vector (e.g., from the bottom-left corner, or from the center outwards), ensuring we find the best possible solution within the strict 30-second time limit.

Challenges we ran into

  • The Objective Function Trap: At first, the algorithm tried to fill every tiny leftover gap with small bays. This improved the area coverage (the exponent) but completely destroyed the Price/Load ratio (the base). We had to implement a strict greedy system that heavily prioritizes high-efficiency bays.
  • False Positives in Geometric Collisions: When trying to place two bays perfectly edge-to-edge, the mathematical library detected it as a collision. We bypassed this by applying a micrometric virtual shrink buffer(-1.0) to the polygons during the validation phase.

Accomplishments that we're proud of

  • Zero-Collision Guarantee: Integrating a pure polygon engine ensures there are absolutely no invalid overlaps, flawlessly dodging columns and respecting the uneven, stepped ceiling heights.
  • Emergent Crystallization: We are incredibly proud that the algorithm doesn't use hardcoded "templates" to build aisles. The formation of dense "face-to-face" rows arises in a purely mathematical and emergent way through our node heuristic and 180-degree rotations.
  • Stability Under Pressure: We successfully achieved a safe cut-off system that interrupts the parallel processes at exactly 27 seconds, guaranteeing that a valid, highly optimized solution is always returned before the judge's timeout.

What we learned

We learned a valuable lesson about overfitting in spatial heuristics. We initially tried to develop ultra-complex versions with Ray-Casting radars and global axis-locks to solve very specific outlier maps. However, we discovered that a slightly more relaxed and organic approach (our Active Node Packing version) generalizes much better and consistently achieves superior scores across a wide variety of asymmetrical geometries.

What's next for Baymaxxing

For Baymaxxing, we envision two main next steps:

  • Regarding the algorithm: To push the boundaries of what our engine can achieve, we plan to rewrite the geometric collision core in a compiled language. This will allow us to evaluate millions of layout permutations within the same time limit.
  • Regarding the platform: We want to evolve our current web application into a fully interactive platform. With this tool, warehouse managers could manually tweak spatial constraints, add new obstacles, or change bay catalogs on the fly, with the algorithm recalculating the optimal layout in real-time.

Built With

Share this project:

Updates