I have a floor plan. I want to take the image and reproduce the same by exchanging zones and optimize the floor layout. I have to code in Python. I tried using Genetic Algorithm but I didn’t get clarity on how to plot the image on grid and further switch the zones and reproduce the new floor plan. Can anyone help ?
Can you show us some code of the genetic algorithm you tried?
This seem like a very hard / complex homework. I won’t write you any code, but I can tell you how I guess I would tackle the issue:
- Encode the Floor Plan as list of numbers (HARD: best if it makes invalid FPs to be rare)
- Write code to draw the FP from the list representation
- Write code to check if a representation is a valid FP (HARD)
- Define exactly what optimization means, what are you measuring on the FP? (HARD)
- Write code that calculates a fitnes value (that is, the measure that will be optimized)
- Write code that generates a population of FPs
- Implement the GA:
- Measure FP fitnes
- Recombine ‘best’ FPs
- Mutate some FPs
- …rince and repeat
It might be slow in Processing Python mode. Maybe you could do this in Python 3 and use Processing Python mode just to show the results (draw the FPs from the numer list)?
Yeah, can you show the initial image also?
I know the process. But I needed help with the code itself.
then you would have to share your code and ask more specific questions, even related to functions or line numbers where you are stuck.
As @Chrisir said, in order to help we need to see your code.
And I would like to know more about the problem itself:
- I wonder how could we represent a generic Floor Plan in a data structure?
- Are the assigned areas fixed or variable? (can the packing area change in size or only position?)
- What are we optimizing exactly?
(looks like there is an industrial process going on, is there a proximity matrix you have as a target? is there a product flow?)
Yeah, very good questions here!
Is the size of the house fixed? So the outer outline always the same?
Are there big machines so that one room has a minimum size (x or y)? So that the machine fits in?
ONE idea, there are other ways of course!
Basically you have a class Room with pos (x,y) and size (x,y) and name.
Then you have a list of the rooms
Now, when you make the room smaller (x), the room right from it gets bigger (x) automatically.
Same for y.
So there is a connection between the rooms. All rooms in one row must be together as wide as the house. All rooms in one column as high.
Also when one room 1 produces product A and product A is needed in room 2, they should be adjacent (are there even conveyor belts?). So this would be a rule set that should be part of the fitness function.
Do you mean that you are scanning an image (like a jpg, or an svg, or…?) as input to your program, and you are trying to detect the geometry from the image?
Or do you have a data file that defines a floor layout, and you are trying to load the data, draw it is a picture, then change the picture that processing.py makes of that layout data by moving the variables around?
Then show the code also please
Just my intuition but it feels like the OP has in fact little understanding of what he/she is asking. Googling the picture provided above leads to duplicate questions on SO that have been down-voted probably due to the lack of research/explanations. In one of those (deleted since) OP clearly says that he/she doesn’t know how/where to start.
I hope the OP will make the effort to articulate the problem in a clearer statement because this is an interesting topic that I would happily read or even elaborate on (if I can).
Other questions that would be interesting to ask:
Is the evolutionary approach mandatory ? Depending on the objective Constraint Programming could be an option too.
Why resorting to computer vision for such a simple layout ? (Why not using rectangles instead ?)