Undefined
By: Guest | Date: Aug 3 2011 13:19 | Format: C# | Expires: never | Size: 589 B | Hits: 1188
- void crossover(float* ind1, float* ind2, float seed)
- {
- //n-Point-Crossover
- int last =0;
- int crosspoints[CROSS_COUNT+1];
- if(CROSS_COUNT%2!=0)
- crosspoints[CROSS_COUNT]=CHROMOSOME_SIZE;
- float new_seed=seed;
- for(int i=0;i<CROSS_COUNT;i++)
- {
- last=(int)last + randomrange(1,CHROMOSOME_SIZE-(CROSS_COUNT-i)-last,new_seed);
- new_seed = random(new_seed);
- crosspoints[i]=last;
- }
- for(int i=1;i<CROSS_COUNT+1;i++)
- {
- if((i-1)%2==0)
- swap(ind1,ind2,crosspoints[i-1],crosspoints[i]);
- }
- }
Latest pastes
1 days ago
1 days ago
2 days ago
3 days ago
5 days ago