Skip to content

Commit

Permalink
Need a minimum value for 'quarter' which is used in the calculation o…
Browse files Browse the repository at this point in the history
…f the next candidate neighbor to test. If quarter is less than 2, we never get movement.
  • Loading branch information
khuck committed Aug 17, 2021
1 parent d028ff5 commit 41cf98a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/apex/simulated_annealing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Variable {
//int delta = (int)(myrandn() * quarter * scope);
int delta = (int)(myrandn() * quarter * scope);
//int delta = myrandn();
//printf("Trying %d...", delta);
if (delta < 0 && (current_index < (size_t)(abs(delta)))) {
// do nothing
//neighbor_index = 0;
Expand All @@ -82,6 +81,12 @@ class Variable {
else {
*((const char**)(value)) = svalues[neighbor_index].c_str();
}
/* std::cout << "scope: " << scope
<< " quarter: " << quarter
<< " delta: " << delta
<< " current_index: " << delta
<< " neighbor_index: " << delta
<< std::endl; */
}
void choose_neighbor() { current_index = neighbor_index; }
void save_best() { best_index = current_index; }
Expand All @@ -91,7 +96,8 @@ class Variable {
maxlen = (std::max(std::max(dvalues.size(),
lvalues.size()), svalues.size())) - 1;
half = maxlen/2;
quarter = (double)half/2;
// we need a minimum value of 2 to get movement at all
quarter = (double)(std::max((half/2), size_t(2)));
current_index = neighbor_index = best_index = half;
//std::cout << "Initialized to " << current_index << std::endl;
}
Expand Down

0 comments on commit 41cf98a

Please sign in to comment.