Free-form floor plan design using differentiable Voronoi diagram

259 points by alex_hirner 9 months ago | 65 comments
  • hansvm 9 months ago
    The general strategy of creating a differentiable representation of a problem and simply describing the constraints is pretty powerful. See also databases (allowing arbitrary knowledge storage to be a tightly integrated part of a larger ML problem), graph layouts (you can do _way_ better than something like graphviz if you add arbitrary differentiable characteristics as constraints in generation -- mixing and matching between the better parts of normal layout routines using your human intuition to say what's important about this graph in particular), ....
    • nobuyuki83 9 months ago
      I am one of the authors, Nobuyuki Umetani from the University of Tokyo, who implemented all the codes. I am delighted to see so many good discussions here!

      I fully understand that the quality of the result is low for the architectural standard. This research does not mean computing a perfect floor plan ready for architectural design. It's more like it gives the architect some rough design choices in the very early design stage.

      This research presents a new shape representation (differentiable Voronoi) for solving layout problems. These challenging problems typically involve geometrical and topological constraints. Existing shape representations are classified mainly into explicit (mesh) and implicit (using an implicit function) representations. While mesh representation is challenging in handling topological change, implicit representation is problematic because the boundary is not explicitly defined. Thus, it is difficult to compute the loss function based on the boundary shape. Differential Voronoi representation has both implicit and explicit representation properties (the wall is defined explicitly while the distance function from sites determines the shape) and is suitable for optimizing geometry and topology together.

      Thank you! I am happy that our research reaches such a large audience!!

      • CMCDragonkai 9 months ago
        Could you expand on the graph layout constraints? I'm working on something that expresses social system architecture and I want something better than force and yed's tooling was interesting but not opensource.
        • hansvm 9 months ago
          Sure! The core of the concept is just building up a library of differentiable constraints you might like to apply to a graph and then mixing and matching (including higher/lower weights on some of the constraints) according to the human intuition you have about the graph you'd like to display.

          - Suppose you want the graph to roughly fit on a page, being neither too big nor too small. This is the basic force-directed graph constraint (edges pull nodes together, all pairs of nodes push each other apart). It's often sub-par by itself because it doesn't explicitly do anything interesting with labels or edges and because it tends to emphasize local clusters while letting the rest of the graph remain fairly busy. If you _want_ to spot clusters and don't care much about other edges (maybe in disease tracking for example), that might not be a bad final result, but it's more useful as a building block onto which you can tack on other behaviors.

          - Suppose the graph has meaningful topology you want to highlight. E.g., you've done a topological level sort on a DAG and want nodes in the same level to be closer to each other than nodes in other levels. Add an error term pulling nodes in the same level together. The above force-directed constraint will then handle the rest of the layout.

          - Laying out nodes is a bit different from laying out edges. If you model your edges as something curvy and differentiable (splines aren't a bad choice, though perhaps add a term minimizing wiggliness too), you can add an error term penalizing too much "busyness" in the graph, e.g. by saying that it's good if you have large regions of whitespace (add up the squared areas of all the connected regions created by your edges and the edges of your bounding box, then negate that to get an error term). This will tend to coalesce edges into meaningful clusters.

          - You might want to add a "confusion" term to your edges. One I like is maximizing the _average_ (not total, otherwise you'll encourage crossings) cosine distance at edge crossings.

          - Force directed layouts naturally minimize edge crossings, but you might want to add an explicit term for that if we're adding in other competing constraints.

          - If you have any human intuition as to what's important in the graph (apologies, "social system architecture" isn't parsing in my brain as a cohesive concept, so I can't provide any concrete examples) then you can tag nodes (and/or edges) with an "importance" factor. The error term you'll likely want is some combination of higher repulsive forces between those nodes and the nodes in the rest of the graph (making the important information distinct), and weaker repulsive forces between the nodes in the other part of the graph (so they take up less space relative to the important structure). A fairly clean way to handle that is a repulsive force proportional to the largest importance squared divided by the smallest importance (or some monotonic function on the constituent large/small parts).

          - Labels are something else you might want to handle well. As with the rest of this, there are lots of error terms you might choose. An easy one is adding a repulsive force from the edges of the label to the other nodes, an attractive force to the parts of the graph the labels should be labeling, and a repulsive force from the edges of the label to the graph edges.

          - An important point is that you can represent basically all of the other interesting graph layouts as just some projected [0] gradient constraint being optimized. E.g., to get a hive plot [1] you impose a radial constraint on nodes according to their assigned groups and just use rules minimizing edge crossings, minimizing confusion at the existing crossings, and maximizing large chunks of whitespace in the graph to meaningfully cluster the edges (also something minimizing wiggliness if your edge description is complicated).

          - And so on. This is quite long. Maybe a good general principle is that if you don't like something about a given layout, if you can quantify what you don't like then you can add that as an explicit error term and get a better graph.

          [0] If you have "hard" constraints which can't be violated, replace gradient descent with projected gradient descent. Take a step according to the gradient, then "project" the parameter vector being optimized to the nearest location not violating those constraints (or, more simply, just project each node/edge/... individually, though convergence will likely be a bit slower).

          [1] https://ggraph.data-imaginist.com/articles/Layouts.html#hive...

          • CMCDragonkai 9 months ago
            Thanks for the detailed response, these are all very interesting constraints, but how would you convert this in an algorithm? It sounds a bit like simulated annealing? I'm aware of gradient descent algorithms used in machine learning, but how would you end up applying this to a graph layout problem?

            Regarding social system architecture, I just mean system architecture, but applied to social systems.

            > - Suppose the graph has meaningful topology you want to highlight. E.g., you've done a topological level sort on a DAG and want nodes in the same level to be closer to each other than nodes in other levels. Add an error term pulling nodes in the same level together. The above force-directed constraint will then handle the rest of the layout.

            An example is like a loose graph of nodes, where we have 2 kinds of nodes, identity nodes and authority nodes. Identities are important - because they are publically discoverable. I want the identity nodes to be more important - and I guess that's where things like topological sort is interesting.

        • sleepydog 9 months ago
          Do you know of a good introduction to this topic?
          • myhf 9 months ago
            Differentiable Programming from Scratch

            https://thenumb.at/Autodiff/

            • Aeolun 9 months ago
              > It all starts with the definition you learn in calculus class

              Whoops, went a step too far already xD

            • hansvm 9 months ago
              Not really. I can find or write one if you're very interested.

              - Gradients (slopes) are incredibly powerful computationally. If you can compute a function, you can compute its slope with almost no overhead. Relating to physical objects, imagine walking at the top of an igloo (where it's pretty flat and you won't lose your balance) vs the sides of an igloo (where it's vertical, and you'll fall over or otherwise break something). For real-world functions. you can ask where you are (top, bottom, middle, ... of the igloo) _and also_ what the slope is (flat, steep, ...) with the second step happening nearly for free.

              - The whole "technique" is that when the things you want aren't being found, walk in the direction of least badness. Gradients define that direction, and since they're nearly free computationally you can abuse them as much as you want.

              - The rest of the "technique" is figuring out how to describe ordinary comp-sci data structures as differentiable entities. E.g., the simplest way to differentiate most discrete objects (like database insertions) is to insert them probabilistically and apply your derivatives/slopes to the likelihood of the insertion succeeding.

              • rsktaker 9 months ago
                I wish all explanations made complicated concepts this manageable!

                > the simplest way to differentiate most discrete objects (like database insertions) is to insert them probabilistically and apply your derivatives/slopes to the likelihood of the insertion succeeding.

                I hope it wouldn't trouble you to go a bit further with this idea? Namely, the idea of differentiating an object or database insertion sounds like it shouldn't be structurally possible.

                And why would there be a probability function for a db insertion succeeding? How could it fail - if the db was full or if there are too many requests?

          • szvsw 9 months ago
            • twelvechairs 9 months ago
              Of course the problems with all of these are

              - They are selecting only parts of the rich tapestry of what is meaningful and useful about an architectural space, which can also vary by culture and by person.

              - They also don't tend to respond to regulation requirements which may be 'hard line' or 'guideline' depending on the place.

              It's a complex world out there for good reason and it doesn't usually reduce well to a few key variables.

              • szvsw 9 months ago
                > They also don't tend to respond to regulation requirements which may be 'hard line' or 'guideline' depending on the place.

                Not sure if you read much of the ones I posted, but they (and the latest version of that work stream in the author’s dissertation) definitely deal with accessibility requirements and so on.

                That’s pretty much the entire point of tools like these - it’s trivially easy to subdivide a polygon, but non-trivially easy to do so while maintaining various constraints, like clearance sizes, connectivity, daylighting requirements, structural requirements, etc etc.

              • DemocracyFTW2 9 months ago
                > rich tapestry

                certainly, let's dive into the rich tapestry of floor plans X-D

              • donw 9 months ago
                This is why I still come to HN.

                The articles may or not be useful, but you can bet that someone in the comments will link to a bunch of other related work.

                • szvsw 9 months ago
                  For sure. Read the author’s dissertation (should be posted on MIT DSpace by now or in the coming weeks) - it’s excellent. He just started teaching at Berkeley - definitely worth following his work. (Disclosure: I wrote all the Python API/web app/infra stuff in the repo above but not any of the underlying algorithms).
                • larodi 9 months ago
                  I knew it Voronoi diagrams are much more than just a shiny topo tool. Incredibly simple approach, and yet so nice results. Kudos.
                • pimlottc 9 months ago
                  I'm no architect, but surely the precise details of the exterior walls are decided based on the floor plan, not the other way around? Seems odd to assume the walls are fixed before the floor plan has been determined.

                  Of course, the shape of the lot and other physical factors put general limitations on the bounds of the house, but filling the entire lot isn't usually the primary goal.

                  Maybe it's more useful for a renovation?

                  • freeone3000 9 months ago
                    I’m not sure why you’d assume that rather than the inverse. The house is set to fit a certain number of square feet based on economic concerns (heating and cooling costs primarily), then the ordinances on setback and separation come into play, then the very clear rectangle that results is your starting point for interior planning.
                    • contingencies 9 months ago
                      Both are used. Hence, any good design should explicitly state what the goals are (ie. what we are optimizing for) before embarking on the design process.

                      Commercial real estate generally optimizes for profit, which means, floor space, however this may be subject to regulation and particularly significant cost constraints (eg. maximum height before alternate structural features required, maximum height of available raw materials, HVAC/insulation, site aspect, site topography).

                      High end residential real estate is perhaps the most interesting, because good residential architecture facilitates aesthetic concern and draws from the full palette of commercial architecture in addition to traditional methods while not being constrained by finance. Hence, very interesting results can sometimes be obtained from good architects who will consider factors such as foliage, natural audio, etc. which are often ~ignored or afterthoughts in commercial/industrial.

                      IMHO good and original design in adequately resourced contexts tends to be iterative and to consider all paths toward a solution, not only a preconceived approach and a waterfall solution.

                      • 9 months ago
                      • rhcom2 9 months ago
                        In my experience in the arch industry this type of space planning is more used in large buildings with a lot of different spaces (think college buildings). Usually the building is already built but being "renovated". A residential house doesn't really have the need for this type of algorithmic design for < 10 rooms.
                        • burningChrome 9 months ago
                          I was thinking the same thing, albeit if someone is remodeling a residential house that has a main floor with a limited space, but the family would like a bigger kitchen, or a smaller living room? I'm wondering if it could be applicable in that scenario, or would be way more overkill than necessary? Taking into account of course of external walls, headers and other necessary limitations that might rule out using something like this?

                          I kind of feel like its overkill, but I'm curious what it would come up with if given a pretty strict boundaries in terms of space and dimensions even on a very large, multi-million dollar house. What's the threshold for when it could be applicable, versus "Yeah, we don't need something this insane to do this."

                          I do agree, it would be completely applicable in large sprawling buildings are being renovated, but are looking at how they can utilize existing space better.

                        • HelloNurse 9 months ago
                          With typical brick and concrete structures there are many fixed, nonnegotiable walls and pillars: load-bearing ones that must be present at a precise location and aligned with their counterparts on higher and lower floors, or external ones that must respect layout limits (e.g. far enough from the street, leaving a sidewalk of suitable width, global limits of the area of the whole building) and aesthetic considerations (e.g. straight without random recesses, symmetrical repeated units). Flexible internal wall are a minority.
                          • jkaptur 9 months ago
                            Strong https://xkcd.com/793/ vibes here, though it's a cool way to approach this model of a problem.
                          • foota 9 months ago
                            This is fascinating to me because I once tried to take a (vaguely) similar approach to generate a procedural city layout, taking a voronoi diagram, and then doing some modified flood fills to create buildings within the city while leavings streets.

                            It feels to me like their approach could be used for this as well, since there's of course nothing that requires it to only be used for generating floor plans.

                            • notjoemama 9 months ago
                              Does anyone know how to forward this to Hello Games so they can work it into No Man’s Sky? lol
                            • javier123454321 9 months ago
                              Geez, as architecture these plans are absolutely horrible and produce unusable spaces. As an abstract math problem, it seems marginally useful, but I would not want to live in a place laid out by this algorithm.
                              • cabidaher 9 months ago
                                As a non-architect, I would love if you could explain some of what makes the non-duck designs _so_ horrible. Some of them looked more than fine to me at first glance. It's also something that can be rerun over and over with little interaction in-between runs so one could generate a handful of designs starting from different seeds and get inspiration.
                                • orthoxerox 9 months ago
                                  You generally want your rooms to be not just rectilinear, but rectangular after you fill in all built-in storage spaces. And storage spaces have to be sized appropriately to their intended purpose: you don't want three-foot-deep shelves. Another thing this optimizer doesn't take into account is corridors. It has the notion of room connections and area ratios, but area ratios are the wrong way to think about corridors: you want them to be as small as possible while still having at least a certain width.
                                  • hwillis 9 months ago
                                    The algorithm prefers rectangular rooms, you'd just need to adjust it a bit. The wall loss function minimizes wall length and tries to regularize angles, so it naturally converges to square-ish rooms:

                                    > we compute the norm of the tangent edge vector, which is equivalent to the norm of the 2D normal direction. Minimizing this loss has the following two effects: simplifying the wall between two adjacent rooms by penalizing its length, and aligning the boundary to the coordinate axis by making the coordinates of the tangent vector sparse in 2D.

                                    The optimizer also seems like it should handle corridors okay as long as the corridor area is set to something reasonable. A corridor is just a room that is allowed to be long; since the other rooms will try to take up relatively square spaces you should be left with a long connecting area.

                                    > And storage spaces have to be sized appropriately to their intended purpose: you don't want three-foot-deep shelves.

                                    Like you said, this is the same minimum/maximum width problem that makes corridors wonky. I think this is relatively easily solved, though. A "minimum width" constraint is really just a requirement that no voronoi site is within X distance of a wall. A shelf is a sub-area in a room where there must be 2 borders within X distance of a voronoi point. Things like furniture and kitchen islands are also basically represented like that, as constrained areas.

                                    A simpler alternative to complex per-point constraints would be to have area constraints per control point- a bunch of single-point "rooms" inside the actual rooms. In the case of a corridor, since the voronoi cells tend towards a square, you just need to set that area to the minimum width and they should avoid shrinking below that width.

                                    • jeroenhd 9 months ago
                                      Based on some of the floor plans I've seen, architects also seem to have developed a habit of designing weird floor plans somewhere after the year 2000. I don't know why they thought apartments could need corridors with diverging or converging walls in the hallways, or why rooms without 90 degree angles are a good idea, but their decisions don't seem that far off the floor plans this tool generates.

                                      These outputs are far from perfect but unfortunately they're not unrealistic.

                                    • javier123454321 9 months ago
                                      If you just look at the plans in the initial diagram. Plan C is the only one that makes marginally useful spaces, avoiding excesive corners and awkward leftover space that ends up without use. It also happens to be the more obvious solution to the problem.

                                      I could see the value in generating a bunch of rooms roughly accounting for the space requirements, but that's usually done in a more abstract way before taking into consideration things like privacy, thoroughfares, building conventions, spans, noise and light access, wind patterns, and things of that nature.

                                    • Aeolun 9 months ago
                                      I don’t think most people would build their office in the shape of a duck. There’s little you can do given those constraints xD
                                      • photonthug 9 months ago
                                        It seems like if you already have a weird space, you can also maybe use this to minimize cuts while you’re adding carpet, or solve constraints about minimizing distance for shared water supply pipes that need to touch the sink and the shower, etc.

                                        That said I actually might want a room shaped like a duck, provided I don’t have to put down the flooring =)

                                      • ivanjermakov 9 months ago
                                        I understand that this might be out of scope of the project, but floor plan design is more convoluted than filling the space with some constraint.

                                        Necessary things to respect:

                                        - recrangular rooms: non-straight angles are hard to work with

                                        - windows: unless this is a plan for the underground floor

                                        - water/waste water supply/vent shaft: for multi-floor buildings cannot be moved

                                        - personal needs: some people need lots of storage space, some a room to play videogames, some a huge kitchen with an isle. All of that must be reflected in a good floor plan

                                        With that said, I feel like this project might be good for less serious application like procedural game design, but is too naive for real architectural use.

                                        • hwillis 9 months ago
                                          Windows and pipes/vents are just constraints. Windows are constraints to outside areas and pipes/vents/stairs are constraints between floors.

                                          Rectangularity is enforced by the wall loss function, which is adjustable.

                                          > personal needs: some people need lots of storage space, some a room to play videogames, some a huge kitchen with an isle.

                                          That's... the point. You decide you want your kitchen to be 20% bigger and the floor plan readjusts itself without needing somebody to draw up a new plan.

                                          > With that said, I feel like this project might be good for less serious application like procedural game design, but is too naive for real architectural use.

                                          Given that this is a paper submission to the Pacific Graphics conference, yes. Architecture is not really the point. You could also point out some much more obvious architectural needs, like the fact that houses need an outside too.

                                          • Rhapso 9 months ago
                                            I suspect this is all well understood by the authors. We do research one simple step at a time, then we sell it as "look at this amazing thing" because we like funding (which enables future research and eating food!)
                                          • geon 9 months ago
                                            What do the cells represent, and why are they more dense in some spots?
                                            • hwillis 9 months ago
                                              The cells are the areas closest to the voronoi sites, the dots inside the cells. The sites are the outputs of the optimizer; it adjusts the sites until the constraints are met well. The number of sites is chosen by the user.

                                              The excess sites will naturally be clustered together and weakly tend away from the interior walls. The optimizer prefers straighter walls, so it tries to cover the room in large cells (which have big straight edges) and then shove the rest of the points into a small area where they aren't affecting the internal walls. Thats why they tend to cluster into the center of internal rooms, or towards exterior corners where the wall is preset.

                                            • digilypse 9 months ago
                                              Really cool. Could see this being used for generative video game assets
                                              • codetrotter 9 months ago
                                                An FPS Death Match map, but every time a new match is started, the layouts of the rooms change somewhat. And maybe even like another commenter talked about, buildings themselves could be positioned using this technique too, so even the layout of the buildings and the roads change a bit every new match.

                                                It’ll be familiar, but at the same time unfamiliar, every time a new match starts. Some strategies will be useful across matches, some strategies will not.

                                                • reportgunner 9 months ago
                                                  Game called 'Due Process' has procedurally generated levels, but they are based on tilesets - I think rooms generated the OP way wouldn't make sense and would be very disorienting.
                                                • readyplayernull 9 months ago
                                                  Recently found a similar game map generator:

                                                  https://mode-vis.gumroad.com/l/IRzH

                                                • rurban 9 months ago
                                                  Cool. In the 90ies I thought similar approaches at our university, and we had practical examples of such constraints. In general city planning was much easier than structural buildings, because gravity and building rules are much stricter than city planning riles, which are trivial.

                                                  We also had rules layed out graphically, and did a substitution process in the optimizations.

                                                  Neufert did help much more than Christopher Alexander.

                                                  • elihu 9 months ago
                                                    This is cool, in part because it's similar to an idea I had awhile back but didn't know how to actually implement it.

                                                    The way I imagined it working was one Voronoi cell per room, but with a tweak where the Voronoi cells are weighted such that you can grow or shrink a Voronoi cell to fit whatever use you have for the room. (At which point it wouldn't really be a Voronoi diagram anymore, but I don't know if there's a name for this other thing. It ought to at least theoretically be possible to compute, because the way soap bubbles stack in 3 dimensions doesn't require all the soap bubbles to contain an exact quantity of air.)

                                                    You could make the case that that isn't really necessary, since you can adjust Voronoi cell size just through the strategic placement of its neighboring cells, but it seemed useful to have an extra axis of control.

                                                    The outer surfaces of the building could be given dome shapes, but it may be more aesthetically pleasing to give them the same angular surfaces as the interior walls by having "imaginary" cells bordering the outside that aren't part of the finished building but instead define its shape.

                                                    I'd imagine the building could either be 3d-printed, or it could be constructed out of flat wall panels that are made in a factory, shipped to the building site, and bolted together (or affixed some other way) at the edges.

                                                    The wall panels could also be shaped so that they form shelves or other usable surfaces out of the strange angles (especially the non-vertical walls).

                                                    Ideally you'd have some program that can endlessly generate floor plan variations based on user input and site geometry, and then lay out all the plumbing and wiring and verify that it meets structural constraints, and the whole design manufactured and assembled without any human designer in the loop at all. No two houses need ever be exactly alike, every major component manufactured on-demand from standard material inputs.

                                                    This would all be pretty hard to setup in reality, but it's how I imagine new construction in near-future science fiction cities, and eventually space habitats working. You spin up an O'Neil cylinder, and some program generates a layout to fill much of the interior with soap-bubble cities like massive mege-structure apartments, but without any repetition. Every neighborhood different than every other, maybe with some common stylistic elements to distinguish one part of town from another, but every location unique, like nature.

                                                    • redandblack 9 months ago
                                                      This will be great for deciding on voting districts
                                                      • IshKebab 9 months ago
                                                        Uhm shouldn't the rooms be rectangular? You don't see many polygonal rooms for obvious reasons...
                                                        • lm28469 9 months ago
                                                          That's the reason architecture is closer to an art than hard science. The most optimal math answer usually sucks ass from a usability/look/&c. point of view