TunerRecord *tuner2 = tunerV->get(tunerNumber + i);
ASSERT( tunerNumber + i < tunerV->getSize());
model_print("Tuner1 = %d \tTuner2 = %d\n", tuner1->getTunerNumber(), tuner2->getTunerNumber());
- ASSERT(scores.contains(tuner1));
- ASSERT(scores.contains(tuner2));
- int score1 = scores.get(tuner1);
- int score2 = scores.get(tuner2);
- if ( score2 > score1 ) {
+
+ int score1, score2;
+ if(!scores.contains(tuner1)){
+ score1 = 0;
+ }else {
+ score1 = scores.get(tuner1);
+ }
+ if(!scores.contains(tuner2)){
+ score2=0;
+ }else {
+ score2= scores.get(tuner2);
+ }
+
+ if( score2 > score1 ){
removeTunerIndex(tunerV, i, allplaces);
- } else if( score2 < score1){
- model_print("score1=%d\tscore2=%d\tt=%u\texp=%f\n", score1, score2, t, exp((score1-score2)*1.0/t));
- double prob = 1/(exp((score1-score2)*1.0/t) );
+ } else if ( score2 < score1) {
+ model_print("score1=%d\tscore2=%d\tt=%u\texp=%f\n", score1, score2, t, exp((score1 - score2) * 1.0 / t));
+ double prob = 1 / (exp((score1 - score2) * 1.0 / t) );
double random = ((double) rand() / (RAND_MAX));
model_print("prob=%f\trandom=%f\n", prob, random);
- if(prob > random){
+ if (prob > random) {
removeTunerIndex(tunerV, i, allplaces);
- }else{
+ } else {
removeTunerIndex(tunerV, tunerNumber + i, allplaces);
}
- } else{
+ } else {
double random = ((double) rand() / (RAND_MAX));
- int index = random > 0.5? i : tunerNumber + i;
+ int index = random > 0.5 ? i : tunerNumber + i;
removeTunerIndex(tunerV, index, allplaces);
}
}