Java – genetic algorithm: request optimization

I am a novice in genetic algorithm. I am assigned to implement genetic algorithm to optimize the request order of pharmacy every working day First, let me explain the problem:

Nine families make requests on any day of the work week (Monday to Friday) The pharmacy can only take care of one to three families a day, no less, and can't repeat any families in the same week The main goal is to optimize the best date for each family to participate, so that the pharmacy will have the largest request every week and impose constraints on the problem The input of the optimization algorithm is the annual average of the number of requests sent by each family For example:

(let's work with only 3 families to simplify the example):

Input:

|Monday | Tuesday | Wednesday | Thursday | Friday F1 | 10 | 20 | 2 | 0 | 7 F2 | 20 | 12 | 0 | 1 | 2 F3 | 2 | 0 | 19 | 3

Possible methods:

|Monday | Tuesday | Wednesday | Thursday | Friday | F2 | F1 | F3|

So far, I have been studying the whole concept of genetics and genetic algorithm I studied particle swarm optimization, but because of my short time, I decided to use a framework I am using jgap, but my main problem is that do I provide a potential solution? I mean, how should I organize genes on chromosomes for mating, reproduction, etc? I've developed the fitness function, but I can't encode the gene the way I want Any suggestions?

Solution

Every family should arrange for one day Therefore, you can store the schedule date for each family One gene will be one in five days, and there will be nine chromium, one for each family

1 2 3 4 5 6 7 8 9
Chrome   M T T F W H T M T

So Monday's family 1, Tuesday's families 2 and 3, and so on You should impose all other restrictions on the fitness function (the pharmacy can only participate in 1 to 3 families per day)

Another code may be

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

So you can take all possible appointments and fill in the family, or leave it blank In this case, the fitness function should ensure that each family has only one appointment

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>