Commit f76461bc authored by Leonardo Solis's avatar Leonardo Solis
Browse files

correction on finding best entity

parent caa567bb
......@@ -107,10 +107,12 @@ float map_angle_360(float angle)
return x;
}
#if 0
// Shift register sizes
// Such registers are used to reduce Initiation Interval (II)
#define SHIFT_REG_SIZE 10
#define SHIFT_REG_SIZE_MINUS_ONE (SHIFT_REG_SIZE-1)
#endif
// --------------------------------------------------------------------------
// Lamarckian Genetic-Algorithm (GA): GA + LS (Local Search)
......@@ -273,6 +275,7 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent,
numwriteports(1)
)) loc_energies[MAX_POPSIZE];
#if 0
// Shift register to reduce II (initially II=6) of best entity for-loop
float shift_reg[SHIFT_REG_SIZE];
......@@ -280,6 +283,7 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent,
for (uchar i=0; i<SHIFT_REG_SIZE; i++) {
shift_reg[i] = 0.0f;
}
#endif
ushort best_entity = 0;
......@@ -288,6 +292,12 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent,
// copy energy to local memory
loc_energies[pop_cnt] = LocalEneCurr[pop_cnt];
#if defined (DEBUG_KRNL_GA)
if (pop_cnt==0) {printf("\n");}
printf("%3u %20.6f\n", pop_cnt, loc_energies[pop_cnt]);
#endif
#if 0
// Identifying best entity
// The enclosing "if (pop_cnt>0) {}" should not be commented
// but it is removed in order to improve performance.
......@@ -301,12 +311,22 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent,
shift_reg[j] = shift_reg[j+1];
}
if (loc_energies[pop_cnt] < shift_reg[0]) {
if (loc_energies[pop_cnt] < shift_reg[SHIFT_REG_SIZE_MINUS_ONE - 1]) {
//if (loc_energies[pop_cnt] < shift_reg[0]) {
best_entity = pop_cnt;
}
//}
#endif
if (loc_energies[pop_cnt] < loc_energies[best_entity]) {
best_entity = pop_cnt;
}
}
#if defined (DEBUG_KRNL_GA)
printf("best_entity: %3u, energy: %20.6f\n", best_entity, loc_energies[best_entity]);
#endif
#pragma ivdep array (LocalPopNext)
#pragma ivdep array (LocalEneNext)
for (ushort new_pop_cnt = 1; new_pop_cnt < DockConst_pop_size; new_pop_cnt++) {
......@@ -438,6 +458,7 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent,
else {
float tmp;
tmp = tmp_offspring + Host_two_absmaxdang*prngGG-DockConst_abs_max_dang;
if (gene_cnt==4) { tmp_offspring = map_angle_180(tmp); }
else { tmp_offspring = map_angle_360(tmp); }
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment