4

I'm new to genetic algorithms and I've been assigned to implement a genetic algorithm to optimize the order of requests per weekday of a pharmacy. First of all, let me explain the problem:

There are 9 families which issue requests to be attended at any day of a work week (monday to friday). The pharmacy can only attend 1 to 3 families per day, no more no less and they can't repeat any family in the same week. The main goal is to optimize the best day for each family to be attended, in that way, the pharmacy attends the maximum requests per week with the constraints imposed on the problem. The input to the optimization algorithm is the annual mean of each number of requests issued by each family. For example:

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

Input:

        | Mon | Tue | 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've been studying the whole concept of genetics and genetic algorithms. I've looked into particle swarm optimization but as my time is rather short, I decided to use a framework. I'm using JGAP, but my main problem is in what way do I present a potential solution? I mean, how should I organize the genes on the chromossome used for mating, breeding, etc...? I've already developed a fitness function, but I can't encode the genes the way I wanted to. Any suggestions?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Henrique Gonçalves
  • 1,572
  • 3
  • 16
  • 27
  • 1
    from what you have described and the example given, I think this problem is a linear combinatorial optimization problem and can be solved by appropriate methods such as simplex or knapsack algorithms (not quite sure which one was more appropriate in this particular case). Do you have to use GA or is that your wish for this project? – posdef Jan 12 '11 at 15:33
  • Are you producing a new schedule each week or are you sorting out several weeks worth of schedules in advance? – Alain Jan 12 '11 at 15:36
  • 2
    With 9 families on 5 days, there are at most 5^9, 1 million, solutions. That's not that much, a simple BFS should do the trick. Or didn't it? – Ishtar Jan 12 '11 at 15:37
  • 1
    Hi, thanks for your comments. I've already thought of those solutions but I really have to use Genetic Algorithms to solve the problem. The idea here is to produce a schedule to use every week and to revise it every 6 months. The values in the input are from the sums of orders of an entire year – Henrique Gonçalves Jan 12 '11 at 15:38
  • why don't you use binary encoding? i.e. 0 for free slot, 1 for not. – Dhruv Gairola Jan 12 '11 at 15:38
  • @iMP you said that you can't encode the genes in the way that you want to... in what way is that? – Kiril Jan 12 '11 at 17:33
  • @Lirik I wanted to encode the chromossome as an array of lists of strings, well basically a possible solution that should be presented to the fitness function is the table I demonstrated as a possible solution on my original post. – Henrique Gonçalves Jan 12 '11 at 18:00

1 Answers1

1

in what way do I present a potential solution?

Every family should be scheduled on a day. So, you could store on what day each family is scheduled. A gene would be one of the 5 days, a chrome would have 9 of these, one for each familiy

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

So family 1 on Monday, family 2 and 3 on Tuesday, etc. You should impose all the other constraints (The pharmacy can only attend 1 to 3 families per day) in the fitness function.

Another encoding could be

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

So you would take all possible appointments and fill in families, or keep them empty. In this case the fitness function should make sure every family has exactly one appointment.

Ishtar
  • 11,542
  • 1
  • 25
  • 31