RoomCraft AI: Solving Room Layouts with Simulated Annealing
The architecture splits the problem into three distinct phases:
1. The Parser: Llama 3.1 (via Groq) takes a natural language description—like a 4x3 bedroom with a north door—and converts it into a Pydantic-validated data structure. This happens in under 1 second.
2. The Optimizer: This is where Simulated Annealing kicks in. Instead of a greedy search that gets stuck in the first "okay" layout, this algorithm mimics metal cooling. It accepts suboptimal moves early on (high "temperature") to escape local optima, then tightens up as it cools to converge on a high-score layout.
3. The Output: Three.js handles the 3D browser render, while ReportLab spits out a PDF technical plan.
From a performance standpoint, the numbers are lean:
The objective function scores layouts from 0 to 100 based on ergonomics, circulation space, and light access. Interestingly, the system provides the top 5 results rather than just one, which is a necessary safety valve since "optimal" is subjective in interior design.
The biggest takeaway here is the AI workflow pattern. Using an LLM for the interface (human → formal data) and a deterministic algorithm for the solution (data → result) is infinitely more reliable than relying on a prompt. It's the difference between guessing where a bed goes and actually calculating the clearance for a door to open.
https://adrianmoreno-dev.com/blog/roomcraft-ai-simulated-annealing-distribucion-habitaciones