I took some time to test the code you suggested, but finally I did. Indeed when using the: x = LFG175shm() % 50 + a, in each iteration, the numbers generated are the same:
LFG175gmLoadToShm (gfibreg);
while (T > 0.0001){
while ((pos1 == 0) || (pos2 == 0) || (pos1 == *municipios) || (pos2 == *municipios) || (pos1 == pos2)){
pos1 = LFG175shm() % 50 + 1;
pos2 = LFG175shm() % 50 + 1;
}
LFG175gmSaveFromShm(gfibreg);
int temp;
temp = solutionM[pos1];
solutionM[pos1] = solutionM[pos2];
solutionM[pos2] = temp;
(...)
T = T * 0.9999;
}
LFG175gmSaveFromShm(gfibreg);
The way it is, the code simply change the same two positions when it had to change two random positions. So I put the code:
while ((pos1 == 0) || (pos2 == 0) || (pos1 == *municipios) || (pos2 == *municipios) || (pos1 == pos2)){
pos1 = LFG175shm()/(0x8000000>>6) + 1;
pos2 = LFG175shm()/(0x8000000>>6) + 1;
}
but the numbers are greater than 64, and are always the same. There’s a way to fix it, sigismondo?
Again, thanks for the answers!