From 0449b430de1143a3ad9e4f54184e288c503d5822 Mon Sep 17 00:00:00 2001 From: Kevin Huck Date: Tue, 24 Sep 2024 14:33:24 -0700 Subject: [PATCH] Debugging nelder mead and removing print statements --- src/apex/nelder_mead.cpp | 8 ++++++-- src/apex/nelder_mead.hpp | 2 ++ src/apex/nelder_mead_internal.h | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/apex/nelder_mead.cpp b/src/apex/nelder_mead.cpp index 602a3149..1994df0c 100644 --- a/src/apex/nelder_mead.cpp +++ b/src/apex/nelder_mead.cpp @@ -30,8 +30,12 @@ void NelderMead::start(void) { for (auto& v : vars) { double r = ((double) std::rand() / (RAND_MAX)); auto& limits = v.second.get_limits(); - tmp.push_back(r * ((limits[1] + limits[0]) / 2.0)); + double range = limits[1] - limits[0]; + double sample_in_range = range * r; + tmp.push_back(limits[0] + sample_in_range); } + //std::cout << "range: [" << lower_limit[i] << "," << upper_limit[i] << "] value: [" + //<< tmp[0] << "," << tmp[1] << "]" << std::endl; init_simplex.push_back(tmp); } searcher = new apex::internal::nelder_mead::Searcher(init_point, init_simplex, lower_limit, upper_limit, true); @@ -91,7 +95,7 @@ void NelderMead::evaluate(double new_cost) { cost = new_cost; // if the function evaluation takes a long time (in nanoseconds, remember), increase our tolerance. auto tmp = std::max((new_cost / 50.0), 1000.0); - std::cout << "new function tolerance: " << tmp << std::endl; + //std::cout << "new function tolerance: " << tmp << std::endl; searcher->function_tolerance(tmp); } k++; diff --git a/src/apex/nelder_mead.hpp b/src/apex/nelder_mead.hpp index 82e2bb80..2d0dff00 100644 --- a/src/apex/nelder_mead.hpp +++ b/src/apex/nelder_mead.hpp @@ -107,12 +107,14 @@ class Variable { // if our variable is continuous, we have been initialized with // two values, the min and the max if (vtype == VariableType::continuous) { + //std::cout << "Not continuous" << std::endl; limits[0] = dvalues[0]; limits[1] = dvalues[1]; // if our variable is discrete, we will use the range from 0 to 1, // and scale that value to the number of descrete values we have to get // an index. } else { + //std::cout << "Continuous" << std::endl; limits[0] = 0.0; limits[1] = 1.0; } diff --git a/src/apex/nelder_mead_internal.h b/src/apex/nelder_mead_internal.h index a21d832d..fe562a07 100644 --- a/src/apex/nelder_mead_internal.h +++ b/src/apex/nelder_mead_internal.h @@ -237,8 +237,8 @@ template class Searcher { gamma = 0.5; delta = 0.5; } - std::cout << alpha << " " << beta << " " << gamma << " " << delta - << std::endl; + //std::cout << alpha << " " << beta << " " << gamma << " " << delta + //<< std::endl; simplex.resize(dimension + 1); if (initial_simplex.empty()) { // Generate initial simplex