Skip to content
Snippets Groups Projects
Commit 577e12d2 authored by Bastian Schlag's avatar Bastian Schlag
Browse files

update AnnealingUtility implementation

parent b25e3c26
No related branches found
No related tags found
1 merge request!802Remove propagator options from vertexing configs and performance upgrades
......@@ -15,7 +15,7 @@
///
/// @return exp(-1./2. * chi2 / temp)
static double gaussFunc(double chi2, double temp) {
return std::exp(-1. / 2. * chi2 / temp);
return std::exp(-chi2 / (2. * temp));
}
void AnnealingUtility::anneal(State& state) const {
......@@ -31,20 +31,20 @@ double AnnealingUtility::getWeight(State& state, double chi2,
const double currentTemp =
m_cfg.setOfTemperatures[state.currentTemperatureIndex];
double allWeights = 0.;
for (auto val : allChi2) {
allWeights += gaussFunc(val, currentTemp);
}
double base = gaussFunc(1., currentTemp);
double denom = std::pow(base, m_cfg.cutOff - chi2);
double actualWeight = gaussFunc(chi2, currentTemp);
for (double val : allChi2) {
denom += std::pow(base, val - chi2);
}
return actualWeight / (gaussFunc(m_cfg.cutOff, currentTemp) + allWeights);
return 1. / denom;
}
double AnnealingUtility::getWeight(State& state, double chi2) const {
const double currentTemp =
m_cfg.setOfTemperatures[state.currentTemperatureIndex];
return gaussFunc(chi2, currentTemp) /
(gaussFunc(m_cfg.cutOff, currentTemp) + gaussFunc(chi2, currentTemp));
return 1. / (1. + gaussFunc(m_cfg.cutOff - chi2, currentTemp));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment