
// Kernel invocation: mutation <<<N_BLOCK,BLOCK_LENGTH>>> (pgpu,randomPM,randomPoint,CHROM_LEN,PROB_MUT);
// N_BLOCK: number of blocks, such that N_BLOCK * BLOCK_LENGTH = POP_SIZE.
// BLOCK_LENGTH: length of each block, such that N_BLOCK * BLOCK_LENGTH = POP_SIZE.
// pgpu: pointer to global memory that stores the population. 
// randomPM: pointer to global memory that stores the random values for mutation.
// randomPoint: pointer to global memory that stores the random points for mutation.
// CHROM_LEN: length of the chromosome.
// PROB_MUT: mutation probability. 

__global__ void mutation(bool *pop, float *randomPM, int *randomPoint, int length, float PROB_MUT){
	
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    float pm = randomPM[idx];   // value for mutation
    int pnt = randomPoint[idx]; // mutation point
	
    if (pm <= PROB_MUT) {
	pop[idx*length+pnt] = !pop[idx*length+pnt];
    }
 
}
