I am trying to write a code for GA to minimize the cost of a system, the problem is that the solution converges towards a local minimum and it gets stuck in it so I can't improve my solution anymore.

it might be my selection method that is causing the problem here is what I have:

```
%----------------------------selection (fittest half) ----------------

probability=ones(1,population/2);
[,IX]=sort(cost(1:population))
dd=sum(1:population);
probability(1:(population/2))=[1:population/2];
probability=fliplr(probability)/dd;

Indexx=IX(1:population/2);

```

then I use Indexx for crossover etc, can anybody suggest a solution ?