| 204 | # pop_mutation_rate: mutation rate in the population |
| 205 | # mutation_rate: probability of a mutation of a bit |
| 206 | def mutation(pop_mutation_rate, mutation_rate): |
| 207 | uallele=0; |
| 208 | for i in range(1,popSize): |
| 209 | up=np.random.random_integers(100) |
| 210 | up=up/100 |
| 211 | if up<=pop_mutation_rate: |
| 212 | for j in range(1,genomeLength): |
| 213 | ualelle=up=np.random.random_integers(100) |
| 214 | ualelle=ualelle/100 |
| 215 | if uallele<=mutation_rate: |
| 216 | nqpv[i,j,0]=qpv[i,j,1] |
| 217 | nqpv[i,j,1]=qpv[i,j,0] |
| 218 | else: |
| 219 | nqpv[i,j,0]=qpv[i,j,0] |
| 220 | nqpv[i,j,1]=qpv[i,j,1] |
| 221 | else: |
| 222 | for j in range(1,genomeLength): |
| 223 | nqpv[i,j,0]=qpv[i,j,0] |
| 224 | nqpv[i,j,1]=qpv[i,j,1] |
| 225 | for i in range(1,popSize): |
| 226 | for j in range(1,genomeLength): |
| 227 | qpv[i,j,0]=nqpv[i,j,0] |
| 228 | qpv[i,j,1]=nqpv[i,j,1] |
| 229 | |
| 230 | ######################################################### |
| 231 | # PERFORMANCE GRAPH # |