<p>The following answer is a shameless self-promotion, but I don't have any other reference. I did some stuff some years ago on how to deal with "premature" local optima in local search algorithms, i.e., when you get stuck too soon in the search. However, this is not a TCS answer, so maybe out of scope for this site.</p>

<p>The paper is this: <a href="http://wonder2.naist.jp/~villagra-m/maxminsat.pdf">Ant Colony Optimization with Adaptive Fitness Function for Satisﬁability Testing</a>. Also check the references.</p>

<p>The idea is to make your fitness landscape to adapt during the search. To do that, you add some weight schemes to the objective function. Then you change the weights according to some rules based on how good or bad your doing. Please consult the paper about how to define these weight schemes.</p>

<p>The target problem in the paper was random MAX-SAT, because that problem has a bunch of feasible solutions with the same fitness, and that gives you a lot of plateaus, and in general evolutionary algorithms don't work very well for MAX-SAT. So changing the landscape really helps. However, it should be easy to adapt the weight schemes to different problems.</p>

CC BY-SA 3.0
2011-08-19T01:08:13.390Z
2011-08-19T01:08:13.390Z
Marcos Villagra
<p>What you've hit upon is the basic mechanism that drives GAs -- convergence to some fixed point that you hope is near optimal. In your case, clearly it isn't. So the name of the game is to try and balance this tendency to drive convergence with the competing interest of exploring the space looking for other solutions. There's no silver bullet for this problem -- you always end up tuning things to suit your particular problem.</p>

<p>In general, there are two ways to do this. One is to delay convergence for longer, thus giving the algorithm more time to find better solutions. You can switch to a weaker selection operator (binary tournament selection for example), you can increase your mutation rate, etc. The other option is to allow the algorithm to converge, but figure out a sensible way to restart the search (as you mentioned, putting random points in tends not to work because their fitness is too low to allow them to survive and contribute to the search).</p>

<p>I'll give an example of the latter approach. There is a relatively-little known algorithm called CHC (Eshelman 1991) that tends to work really well for a lot of problems. Unfortunately, one reason it's little-known is that the only way to access the original paper is to buy the printed proceedings of the first FOGA conference, but you can probably find a little bit of information online, hopefully enough to get you started. I can give you something of a quick overview though. In rough pseudocode, CHC looks like</p>

<pre><code>delta = k/4               # k = chromosome length
while not done
    create new child population
    for i = 1 to n/2     # n = population size
        select p1, p2 from population without replacement
        if hamming_distance(p1, p2) &gt; delta
            c1, c2 = HUX crossover(p1, p2)
            insert c1, c2 into child pop
        end if
    end for
    if child pop is empty
        delta = delta - 1
    else
        take best n individuals from union of parent and child populations as next population
    end if
    if delta &lt; 0
        keep one copy of best individual in population
        generate n-1 new population members by flipping 35% of the bits of the best individual
        delta = k/4
    end if
</code></pre>

<p>The HUX crossover operator is like uniform crossover, but instead of choosing randomly between the parents independently for each bit, it exchanges precisely half the differing bits from the parents. </p>

<p>You then just keep running this loop until you decide to quit, either because you've found a good enough solution, you've exhausted the amount of time you have to spend on the problem, or whatever other criteria you desire.</p>

CC BY-SA 3.0
2011-08-18T23:23:35.583Z
Thanks for your suggestion. I'll give it a go. My mutation rate most of the times are 0.8. I've just set it to 1 and put binary tournament selection on (previously I had 4-5 tournament size). And the population size is double the usual one (200 members vs 96) to increase diversity. The program is running now. See if it gives better results..
trailmax
CC BY-SA 4.0
2021-10-27T20:20:08.057Z
@deong Hello, according to the rough pseudocode you presented above, it seems like there will be no identical parents in each generation. Is that right? But based on understanding, identical parents are allowed in each generation.
czy
CC BY-SA 4.0
2022-01-25T14:02:47.750Z
CHC will never pick the same individual from the population twice, but the population can contain many identical copies of the same individual, so it can and will pick two "different" individuals that have the same genotype and fitness. When that happens, no offspring will be created. When it happens frequently enough, you may get through the entire iteration with no offspring created at all. That triggers decrementing delta. Reducing that value allows parents to be more similar to each other and still produce offspring. When delta hits zero, you reseed and restart.
deong
CC BY-SA 3.0
2011-08-18T22:56:47.430Z
2011-08-18T22:56:47.430Z
deong
<p>I'm using Genetic Algorithm to create a rota for home-care organisation. All the groundwork is complete, I'm getting the results, but results are not as good as expected. 
If I calculate fitness for existing rota made by somebody, I get about £6000 (I measure fitness in money - great point for management). </p>

<p>When I run my GA, the best I manage to get is £8K after about 30K generations. 
So I know the better solution exists and I'm trying to get better result. 
I have tried different approaches - big population, small population, different number of crossover points, swap-mutation, random-mutation, hill-climber-mutation. 
And nothing improved the results. </p>

<p>The resulting curve looks like this: 
<img src="https://i.sstatic.net/J7VhW.png" alt="Improvement rate"></p>

<p>I can run GA much longer, but it does not give me any better results - the curve is just flat horizontal to the right.</p>

<p>I figured that I get quite a lot of duplicated individuals in final population. And that slows down the improvement of the solution. 
I learned how to find duplicate individuals. But what do I do with them? I have tried replacing them with randomly created solutions, but usually their fitness is much worse then every body else in the solution space, so they get "killed" quite soon without giving any offsprings or other influence to the solution space. </p>

<p>Any ideas/suggestions/papers will be highly appreciated, as I've run out of ideas and research papers and almost no time left. </p>

<p><strong>UPD:</strong> some description of the problem: 
There are number of visits(shifts) that are located in different geographical places (distances between locations are known). Currently I work with 700 visits per week with durations from 30 minutes to 5hrs. There are workers with different levels of contractual arrangements: some have 0 contracted hours - relief workers, there are part-timers and full-timers.
I need to allocated workers for every shift in a best possible manner with this factors in mind:</p>

<ol>
<li>Minimise travel distance for workers. When they have number of shifts in a day, the locations should be roughly in the same area</li>
<li>Workers should not do a lot of overtime hours</li>
<li>Workers should not work less than their contract says</li>
<li>Workers with 0-contracts should be allocated no or very limited working hours</li>
<li>Minimise waiting time between shifts. So no situations when somebody starts one visit at 9am to 10am, and next  visit is at 6pm.</li>
<li>There is a limit of total number of hours that can be worked per day</li>
<li>There is a minimum of working hours per day: nobody should be deployed for only 30-minute visit and no other visits per day. </li>
<li>At least 2 days off allocated for anybody, but can be more</li>
<li>At least 2 days off must be adjacent.</li>
</ol>

<p>And other minor fitness function adjustments.
I hope this is sufficient for description.</p>

CC BY-SA 3.0
2011-08-18T22:37:18.397Z
Not really an answer to your question, but I would like to ask if you can provide some information about your problem. I'm asking because if you know a few things about the problem maybe it would be better to use some other method. Genetic algorithms should only be considered (in my opinion) if you don't know anything about your problem (and even then other methods may be better/faster).
George
CC BY-SA 3.0
2011-08-18T22:48:03.397Z
This is actually thesis on GA and scheduling, so no option to change GA to other methods. I'll put some more details on the problem as an update.
trailmax
CC BY-SA 3.0
2011-08-18T23:02:13.140Z
@George B. please see update to the post with problem description
trailmax
CC BY-SA 3.0
2011-08-19T00:02:05.040Z
Not an expert on the topic, but IMHO you have a better chance of getting help with this on [MetaOptimize](http://metaoptimize.com). (Also the question seems too localized to me, it might become more interesting for others if you also state the problem in more general terms, e.g. "*What are the known methods to reduce the number of duplicates in the final population of a Genetic Algorithm?*")
Kaveh
CC BY-SA 3.0
2011-08-19T02:51:28.953Z
A feature that is sometimes overlooked is how you design the genotype. Making some tweaks to how genotype encoded given phenotypes might help you find higher plateaus, a good place to start when engineering the genotype is [schema theory](http://cstheory.stackexchange.com/q/555/1037).
Artem Kaznatcheev
<ne.neural-evol><scheduling><genetic-algorithms>
Dealing with duplicates in Genetic Algorithm
trailmax
# Dealing with duplicates in Genetic Algorithm

(Asked by: username_0 on 2011-08-18)

I'm using Genetic Algorithm to create a rota for home-care organisation. All the groundwork is complete, I'm getting the results, but results are not as good as expected.
If I calculate fitness for existing rota made by somebody, I get about £6000 (I measure fitness in money - great point for management).

When I run my GA, the best I manage to get is £8K after about 30K generations.
So I know the better solution exists and I'm trying to get better result.
I have tried different approaches - big population, small population, different number of crossover points, swap-mutation, random-mutation, hill-climber-mutation.
And nothing improved the results.

The resulting curve looks like this:
![Improvement rate](https://i.sstatic.net/J7VhW.png)

I can run GA much longer, but it does not give me any better results - the curve is just flat horizontal to the right.

I figured that I get quite a lot of duplicated individuals in final population. And that slows down the improvement of the solution.
I learned how to find duplicate individuals. But what do I do with them? I have tried replacing them with randomly created solutions, but usually their fitness is much worse then every body else in the solution space, so they get "killed" quite soon without giving any offsprings or other influence to the solution space.

Any ideas/suggestions/papers will be highly appreciated, as I've run out of ideas and research papers and almost no time left.

**UPD:** some description of the problem:
There are number of visits(shifts) that are located in different geographical places (distances between locations are known). Currently I work with 700 visits per week with durations from 30 minutes to 5hrs. There are workers with different levels of contractual arrangements: some have 0 contracted hours - relief workers, there are part-timers and full-timers.
I need to allocated workers for every shift in a best possible manner with this factors in mind:

1. Minimise travel distance for workers. When they have number of shifts in a day, the locations should be roughly in the same area
2. Workers should not do a lot of overtime hours
3. Workers should not work less than their contract says
4. Workers with 0-contracts should be allocated no or very limited working hours
5. Minimise waiting time between shifts. So no situations when somebody starts one visit at 9am to 10am, and next visit is at 6pm.
6. There is a limit of total number of hours that can be worked per day
7. There is a minimum of working hours per day: nobody should be deployed for only 30-minute visit and no other visits per day.
8. At least 2 days off allocated for anybody, but can be more
9. At least 2 days off must be adjacent.

And other minor fitness function adjustments.
I hope this is sufficient for description.

**Tags:** ne.neural-evol, scheduling, genetic-algorithms

> **Comments:**
> **username_1**: Not really an answer to your question, but I would like to ask if you can provide some information about your problem. I'm asking because if you know a few things about the problem maybe it would be better to use some other method. Genetic algorithms should only be considered (in my opinion) if you don't know anything about your problem (and even then other methods may be better/faster).  
> **username_0**: This is actually thesis on GA and scheduling, so no option to change GA to other methods. I'll put some more details on the problem as an update.  
> **username_0**: @username_1 B. please see update to the post with problem description  
> **username_2**: Not an expert on the topic, but IMHO you have a better chance of getting help with this on [MetaOptimize](http://metaoptimize.com). (Also the question seems too localized to me, it might become more interesting for others if you also state the problem in more general terms, e.g. "*What are the known methods to reduce the number of duplicates in the final population of a Genetic Algorithm?*")  
> **username_3**: A feature that is sometimes overlooked is how you design the genotype. Making some tweaks to how genotype encoded given phenotypes might help you find higher plateaus, a good place to start when engineering the genotype is [schema theory](http://cstheory.stackexchange.com/q/555/1037).  

---

## 2 answers

### Answer by username_5 on 2011-08-18. Score: 9 | Accepted answer

What you've hit upon is the basic mechanism that drives GAs -- convergence to some fixed point that you hope is near optimal. In your case, clearly it isn't. So the name of the game is to try and balance this tendency to drive convergence with the competing interest of exploring the space looking for other solutions. There's no silver bullet for this problem -- you always end up tuning things to suit your particular problem.
In general, there are two ways to do this. One is to delay convergence for longer, thus giving the algorithm more time to find better solutions. You can switch to a weaker selection operator (binary tournament selection for example), you can increase your mutation rate, etc. The other option is to allow the algorithm to converge, but figure out a sensible way to restart the search (as you mentioned, putting random points in tends not to work because their fitness is too low to allow them to survive and contribute to the search).
I'll give an example of the latter approach. There is a relatively-little known algorithm called CHC (Eshelman 1991) that tends to work really well for a lot of problems. Unfortunately, one reason it's little-known is that the only way to access the original paper is to buy the printed proceedings of the first FOGA conference, but you can probably find a little bit of information online, hopefully enough to get you started. I can give you something of a quick overview though. In rough pseudocode, CHC looks like
delta = k/4               # k = chromosome length
while not done
    create new child population
    for i = 1 to n/2     # n = population size
        select p1, p2 from population without replacement
        if hamming_distance(p1, p2) > delta
            c1, c2 = HUX crossover(p1, p2)
            insert c1, c2 into child pop
        end if
    end for
    if child pop is empty
        delta = delta - 1
    else
        take best n individuals from union of parent and child populations as next population
    end if
    if delta < 0
        keep one copy of best individual in population
        generate n-1 new population members by flipping 35% of the bits of the best individual
        delta = k/4
    end if

The HUX crossover operator is like uniform crossover, but instead of choosing randomly between the parents independently for each bit, it exchanges precisely half the differing bits from the parents. 
You then just keep running this loop until you decide to quit, either because you've found a good enough solution, you've exhausted the amount of time you have to spend on the problem, or whatever other criteria you desire.

> **Comments:**
> **username_0**: Thanks for your suggestion. I'll give it a go. My mutation rate most of the times are 0.8. I've just set it to 1 and put binary tournament selection on (previously I had 4-5 tournament size). And the population size is double the usual one (200 members vs 96) to increase diversity. The program is running now. See if it gives better results..  
> **username_6**: @username_5 Hello, according to the rough pseudocode you presented above, it seems like there will be no identical parents in each generation. Is that right? But based on understanding, identical parents are allowed in each generation.  
> **username_5**: CHC will never pick the same individual from the population twice, but the population can contain many identical copies of the same individual, so it can and will pick two "different" individuals that have the same genotype and fitness. When that happens, no offspring will be created. When it happens frequently enough, you may get through the entire iteration with no offspring created at all. That triggers decrementing delta. Reducing that value allows parents to be more similar to each other and still produce offspring. When delta hits zero, you reseed and restart.  

---

### Answer by username_4 on 2011-08-19. Score: 6

The following answer is a shameless self-promotion, but I don't have any other reference. I did some stuff some years ago on how to deal with "premature" local optima in local search algorithms, i.e., when you get stuck too soon in the search. However, this is not a TCS answer, so maybe out of scope for this site.

The paper is this: [Ant Colony Optimization with Adaptive Fitness Function for Satisﬁability Testing](http://wonder2.naist.jp/~villagra-m/maxminsat.pdf). Also check the references.

The idea is to make your fitness landscape to adapt during the search. To do that, you add some weight schemes to the objective function. Then you change the weights according to some rules based on how good or bad your doing. Please consult the paper about how to define these weight schemes.

The target problem in the paper was random MAX-SAT, because that problem has a bunch of feasible solutions with the same fitness, and that gives you a lot of plateaus, and in general evolutionary algorithms don't work very well for MAX-SAT. So changing the landscape really helps. However, it should be easy to adapt the weight schemes to different problems.


---

