diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-12-21 15:51:57 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-12-21 15:51:57 -0500 |
commit | 47546b445b18cbc13892702cabd4c22968a9bde9 (patch) | |
tree | 71bbe199b78b488e34118ed0ae355baf5909b05c /hadamard_pt.hpp | |
parent | 5f947be0d1d4af7d777c6af569f8ce5ead1f76a4 (diff) | |
download | code-47546b445b18cbc13892702cabd4c22968a9bde9.tar.gz code-47546b445b18cbc13892702cabd4c22968a9bde9.tar.bz2 code-47546b445b18cbc13892702cabd4c22968a9bde9.zip |
now using random choice of pairs to swap instead of sweeping left to right
Diffstat (limited to 'hadamard_pt.hpp')
-rw-r--r-- | hadamard_pt.hpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/hadamard_pt.hpp b/hadamard_pt.hpp index 67cb710..9365e50 100644 --- a/hadamard_pt.hpp +++ b/hadamard_pt.hpp @@ -11,7 +11,6 @@ void swap(MCMC& s1, MCMC& s2) { class ParallelMeasurement { public: virtual void after_step(bool, unsigned, double, double, const MCMC&, const MCMC&){}; - virtual void after_sweep(const std::vector<MCMC>&){}; }; typedef struct range { @@ -57,13 +56,6 @@ public: return accepted; } - void sweep(bool dry = false) { - - for (unsigned i = 0; i < Ms.size() - 1; i++) { - this->step(i, i + 1, dry); - } - } - std::vector<double> tune(unsigned n0, unsigned m, double ε, double ε2) { unsigned n = n0; @@ -82,7 +74,7 @@ public: } for (unsigned k = 0; k < m * Ms.size() - 1; k++) { - unsigned j = Ms[0].rng.uniform((unsigned)0, (unsigned)(Ms.size() - 2)); + unsigned j = rng.uniform((unsigned)0, (unsigned)(Ms.size() - 2)); if (this->step(j, j + 1, true)) { std::swap(colors[j], colors[j + 1]); @@ -165,9 +157,9 @@ public: for (unsigned j = 0; j < Ms.size(); j++) { Ms[j].run(m, dry); } - this->sweep(dry); - if (!dry) { - B.after_sweep(this->Ms); + for (unsigned j = 0; j < Ms.size() * m; j++) { + unsigned k = rng.uniform((unsigned)0, (unsigned)(Ms.size() - 2)); + this->step(k, k + 1, dry); } } } |