Answer the question
In order to leave comments, you need to log in
Arrangement of elements on the board. How to implement using genetic algorithms?
There are elements that are known (Height, Width).
There is a matrix of connections (Which elements are interconnected and the number of connections)
Below is an example:
These elements need to be placed on the board using the Genetic Algorithm.
Below is an example:
While I'm doing this:
1) Take the element that has the most connections and Place it on the board
2) Take the element that has the most connections with the placed ones
3) And so on until the end
Placement goes like this:
We consider all the cells and look for the optimal cell (coinciding with the upper left corner of the element) to place the next element.
And now you need to use the Genetic Algorithm.
Answer the question
In order to leave comments, you need to log in
You have to start with the aspect ratio.
This is the purpose of the algorithm.
Then, you need to scatter arbitrary elements into 2 piles (starting with the largest in size!), As close as possible to the goal (proportions of the sides of the board).
Then, you begin to swap (swap) those elements of different heaps that will give an even greater approximation to the goal, and so on until optimization becomes impossible.
Stop the algorithm and get placement using GA.
Genetic algorithm like this:
First, we develop a way to encode. For example [Item number, coordinates, location].
We run the algorithm, and it gives out a bunch of numbers of the "genetic code", which we turn into a fetotype: we sequentially place all [Element number, coordinates, location] on an empty board.
We are trying to connect all the elements in the right order.
After that, we count collisions: intersections of elements (there was not enough space), invalid intersections of links, etc. bugs. As an answer for the GA, the number of collisions of the given genome is given. The algorithm tries to find such a sequence that there would be fewer collisions (different collisions can have different weights).
PS no one forbids analyzing the genome to identify obvious bugs (for example, the same element 5 times or coordinates outside the board, etc.) and correction (by "correction" is meant any action that tries to improve the situation, most often random ). The more such heuristics there are, the (potentially) faster the algorithm will converge.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question