diff --git a/src/apex/simulated_annealing.cpp b/src/apex/simulated_annealing.cpp index 33f7f893..79e544d5 100644 --- a/src/apex/simulated_annealing.cpp +++ b/src/apex/simulated_annealing.cpp @@ -32,7 +32,12 @@ size_t SimulatedAnnealing::get_max_iterations() { } //return max_iter / vars.size(); //return max_iter * vars.size() *vars.size(); - auto foo = std::min(max_iterations, (std::max(min_iterations, max_iter*vars.size()))); + auto foo = max_iter; + if (vars.size() == 1) { + foo = max_iter * max_iter; + } else { + foo = std::min(max_iterations, (std::max(min_iterations, max_iter))); + } //std::cout << "Max iterations: " << foo << std::endl; return foo; } diff --git a/src/apex/simulated_annealing.hpp b/src/apex/simulated_annealing.hpp index 59911770..7af8939e 100644 --- a/src/apex/simulated_annealing.hpp +++ b/src/apex/simulated_annealing.hpp @@ -188,7 +188,12 @@ class SimulatedAnnealing { kmax = get_max_iterations(); /* get max iterations */ //std::cout << vars.size() << " Vars, Max iterations : " << kmax << std::endl; - restart = kmax / 10; + // prevent restart getting set to 0 + if (kmax < 10) { + restart = kmax; + } else { + restart = kmax / 10; + } } };