Undefined
By: Guest | Date: Aug 3 2011 13:19 | Format: C# | Expires: never | Size: 589 B | Hits: 1193
- 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
48 minutes ago
10 hours ago
1 days ago
2 days ago
2 days ago