summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-12-19 23:53:36 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-12-19 23:53:36 -0500
commit2a419c1324f6ffd59e92c0b63f0b890195bf5b1b (patch)
tree05fa6f9929f6b776026426dd2927e74bac6bb9c7
parent9f83692c20d5c777000bb8d1eeb48ee66892bac8 (diff)
downloadcode-2a419c1324f6ffd59e92c0b63f0b890195bf5b1b.tar.gz
code-2a419c1324f6ffd59e92c0b63f0b890195bf5b1b.tar.bz2
code-2a419c1324f6ffd59e92c0b63f0b890195bf5b1b.zip
new conditions for stopping tuning
-rw-r--r--hadamard.cpp2
-rw-r--r--hadamard_pt.hpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/hadamard.cpp b/hadamard.cpp
index fef5af2..5154677 100644
--- a/hadamard.cpp
+++ b/hadamard.cpp
@@ -116,7 +116,7 @@ int main(int argc, char* argv[]) {
std::cout << "Beginning simulation of " << n << ".\n";
std::cout << "Beginning " << n_tuning << " tuning tempering updates of " << M
<< " sweeps each.\n";
- std::vector<double> f = p.tune(n_tuning, M, ε, ε2);
+ p.tune(n_tuning, M, ε, ε2);
std::cout << "Finished tuning, beginning " << m << " measurement tempering updates of " << M
<< " sweeps each.\n";
p.run(m, M);
diff --git a/hadamard_pt.hpp b/hadamard_pt.hpp
index 5500f57..812186d 100644
--- a/hadamard_pt.hpp
+++ b/hadamard_pt.hpp
@@ -64,7 +64,7 @@ public:
}
}
- std::vector<double> tune(unsigned n0, unsigned m, double ε, double ε2) {
+ void tune(unsigned n0, unsigned m, double ε, double ε2) {
unsigned n = n0;
@@ -148,12 +148,12 @@ public:
}
for (unsigned i = 0; i < T1.size(); i++) {
- err += fabs(T1[i] - 1/ Ms[Ms.size() - i - 2].β) / T1[i];
+ err += fabs(T1[i] - 1/ Ms[Ms.size() - i - 2].β);
Ms[Ms.size() - i - 2].β = 1 / T1[i];
}
- if (err / T1.size() < ε2) {
- return f;
+ if (err / T1.size() * Ms.size() / (1/Ms.front().β - 1/Ms.back().β) < ε2) {
+ break;
}
n *= 2;