# 2d bin packing + selective grouping of objects (?)

This topic is 1868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone!

Let me introduce myself, my name is Francisco and I'm an architecture student. I've recently become interested in algorithmic design, which is basically utilizing math to help design (an example would be structure or space optimization). To contextualize, I'm a noob with numbers, so as far as algorithmic architecture goes, I´ve just played with some tools that help with it (Rhino Grasshopper for example, which is a 3d parametric modeler).

I want to develop a software in which I input areas (represented by rectangles) and it organizes them and presents me various possible solutions to a floor plan. I will learn programming to try and develop this, but I have so little knowledge in programming that I don't know how to tackle the problem directly.

The problem consists in trying to group a bunch of rectangles in the least possible space (not within a container, no boundaries). at the same time, I want some of these rectangles to be closer to others, so there is a hierarchy of proximity between rectangles. For example, if I wanted various possibilites of a house floor plan, I'd input spaces such as kitchen, dinning room, living room, bedrooms, etc., and it would not only group them in little space, but also ubicate them according to desirable proximities (kitchen - dinning room for example) and viceversa.

So basically, it would be some sort of 2d bin packing, but is there a way to control how the objects "pack" so I have the desirable proximities between them?

Is it possible to develop a genetic algorithm with multiple fitnesses? so it searches for various solutions taking into consideration ALL of the desirable conditions (least total space, and all the proximity conditions between objects).

Thanks in advance, open to suggestions,ideas or anything.

##### Share on other sites
[quote name='Pixbae' timestamp='1354643439' post='5007144']
Is it possible to develop a genetic algorithm with multiple fitnesses? so it searches for various solutions taking into consideration ALL of the desirable conditions (least total space, and all the proximity conditions between objects).
[/quote]

I think this is the key of what you are asking. You need to combine your fitness functions into a single function, which expresses how satisfied you are with a hypothetical solution. This requires careful thought, but it's basically always possible. Then you need an optimization algorithm to find configurations that reach high values of your fitness function. Genetic algorithms are only one possibly optimization algorithm, and probably not my first choice here. But figuring out what you are optimizing for is much more important than how you optimize it.

In some contexts it helps to put a dollar value on things. For instance, imagine the value of a house is increased if the kitchen is close to the dining room, and if the bedrooms are far away from the washing machine. Put a dollar value on those things, and then design the floor plan that is worth the most money.

##### Share on other sites
[quote name='Pixbae' timestamp='1354643439' post='5007144']The problem consists in trying to group a bunch of rectangles in the least possible space (not within a container, no boundaries).[/quote]You'll have to give an exact definition of "least possible space". A bunch of rectangles always takes the same area no matter how you put them down. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

This isn't a bin packing problem. Rather, it's akin to VLSI layout problems. Hardcore applied math and algorithm tuning, very challenging stuff. Here's a paper that has some discussion of alternative approaches and has a ton of citations and keywords with which you can find out more.
[url="http://cs.stanford.edu/people/eschkufz/research/a181-merrell.pdf"]http://cs.stanford.e...181-merrell.pdf[/url]

I am heading towards a M.Sc. in computer science, and frankly this would be too painful for me at my current skill level. The challenge is in understanding the relevant math and CS theory; implementing/coding is easy in comparison, since in this application you don't need a fast implementation.

##### Share on other sites
[quote name='Stroppy Katamari' timestamp='1354663863' post='5007226']
[quote name='Pixbae' timestamp='1354643439' post='5007144']The problem consists in trying to group a bunch of rectangles in the least possible space (not within a container, no boundaries).[/quote]You'll have to give an exact definition of "least possible space". A bunch of rectangles always takes the same area no matter how you put them down. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img][/quote]

Good point. The two obvious ones are the area of the convex hull and the area of the bounding axis-aligned rectangle.

[quote]I am heading towards a M.Sc. in computer science, and frankly this would be too painful for me at my current skill level. The challenge is in understanding the relevant math and CS theory; implementing/coding is easy in comparison, since in this application you don't need a fast implementation.
[/quote]

Getting started with optimization problems is not as hard as you might think. I give you two ideas.

For the first idea, you need a procedure to build a configuration step by step (adding a rectangle at a time), and then you can use some version of Monte Carlo search. As a first approach, throw all the rectangles at random a few million times and see what configuration gets the highest score. You can also collect statistics about the first steps and try promising steps more often. I have used the UCT algorithm for this kind of thing before.

The second idea is to use simulated annealing. If you have a way to make small changes to existing configurations (change the location of one rectangle?), you can get something working in a couple of hours.

##### Share on other sites
[quote name='Álvaro' timestamp='1354669669' post='5007252']
Getting started with optimization problems is not as hard as you might think. I give you two ideas.
[/quote]I don't think it's hard to get started with optimization problems. What I suspect is hard is designing and tuning an algorithm for the OP's question that produces actually useful results.

If you manage to find great ready-made solutions which just need to be implemented, that's a different matter.

##### Share on other sites
[quote name='Stroppy Katamari' timestamp='1354726415' post='5007439']
[quote name='Álvaro' timestamp='1354669669' post='5007252']
Getting started with optimization problems is not as hard as you might think. I give you two ideas.
[/quote]I don't think it's hard to get started with optimization problems. What I suspect is hard is designing and tuning an algorithm for the OP's question that produces actually useful results.
[/quote]

My experience has always been the opposite. If you know what you are optimizing for, it doesn't take much effort to put together an optimization algorithm that will produce useful results. When the results are not useful, it's usually because the fitness function wasn't properly described, and you need to think of ways to describe what you don't like about the solution as a term in the fitness function. After a few iterations, the results are usually perfectly good.