Genetic Algorithm: Query Optimization

I am new to genetic algorithms, and I have been instructed to implement a genetic algorithm to optimize the order of requests on a pharmacy's weekday. First of all, let me explain the problem:

There are 9 families that apply for participation on any day of the working week (Monday to Friday). A pharmacy can only visit 1-3 families per day, nothing more, and they cannot repeat any family in the same week. The main goal is to optimize the best day for every family that will be present, so the pharmacy visits the maximum requests per week with restrictions on the problem. The input of the optimization algorithm is the average of each number of requests issued by each family. For instance:

(let it only work with three families to simplify the example):

Input:

Wed | Thu | Fri
F1 | 10 | 20 | 2 | 0 7
F2 | 20 | 12 | 0 | 1 | 2
F3 | 2 | 0 | 0 | 19 | 3

Possible Solution:

| Mon | Tue | Wed | Thu | Fri
| | F2 | F1 | F3 |

So far, I have studied the whole concept of genetics and genetic algorithms. I studied particle piano optimization, but since my time is pretty short, I decided to use a framework. I use JGAP, but my main problem is how can I present a potential solution? I mean, how do I organize the genes on the chromosome used for pairing, breeding, etc.? I have already developed a fitness function, but I cannot code genes the way I wanted. Any suggestions?

+4
source share
1 answer

How can I present a potential solution?

Each family should be scheduled for the day. This way you can save on which day each family is scheduled. The gene will be one of 5 days, chromium will have 9 of them, one for each family

1 2 3 4 5 6 7 8 9 Chrome MTTFWHTMT 

So, family 1 on Monday, family 2 and 3 on Tuesday, etc. In the fitness function, you must impose all other restrictions ( The pharmacy can only attend 1 to 3 families per day ).

Other encoding may be

  M1 M2 M3 T1 T2 T3 W1 W2 W3 ... F2 F3 1 2 - - 5 - 9 - 3 ... 4 - 

Therefore, you must accept all possible meetings and fill out families or leave them empty. In this case, the fitness function should ensure that each family has exactly one meeting.

+1
source

Source: https://habr.com/ru/post/1335265/


All Articles