diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2021-01-15 16:29:59 +0100 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2021-01-15 16:29:59 +0100 |
commit | 199b129c08242be6a2726aae3c9918ca2f2484f7 (patch) | |
tree | 1c80eb9ebac19f3d861beda350542d9ac1ed7b83 /langevin.cpp | |
parent | 136fcddcd38d0b8f3b40faf7c1cb7365d9b2a753 (diff) | |
download | code-199b129c08242be6a2726aae3c9918ca2f2484f7.tar.gz code-199b129c08242be6a2726aae3c9918ca2f2484f7.tar.bz2 code-199b129c08242be6a2726aae3c9918ca2f2484f7.zip |
More changes.
Diffstat (limited to 'langevin.cpp')
-rw-r--r-- | langevin.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/langevin.cpp b/langevin.cpp index 870879b..5ca2d72 100644 --- a/langevin.cpp +++ b/langevin.cpp @@ -83,11 +83,41 @@ int main(int argc, char* argv[]) { ComplexVector z0 = normalize(randomVector<Complex>(N, d, r.engine())); ComplexVector zSaddle = findSaddle(J, z0, ε); - ComplexVector zSaddlePrev = ComplexVector::Zero(N); ComplexVector z = zSaddle; + std::function<double(const ComplexTensor&, const ComplexVector&)> energyNormGrad = [] + (const ComplexTensor& J, const ComplexVector& z) { + double W; + std::tie(W, std::ignore) = WdW(J, z); + return W; + }; + + double aGoal = 1e3; + + std::function<double(const ComplexTensor&, const ComplexVector&)> energyInvA = [aGoal] + (const ComplexTensor& J, const ComplexVector& z) { + double a = z.squaredNorm(); + if (a > aGoal) { + return -aGoal; + } else { + return -z.squaredNorm(); + } + }; + + while (zSaddle.squaredNorm() < aGoal) { + std::tie(std::ignore, z) = metropolis(J, z, energyInvA, T, γ, 100, d, r.engine()); + try { + std::cerr << "Starting descent from " << z.squaredNorm() << "." << std::endl; + zSaddle = findSaddle(J, z, ε); + } catch (std::exception& e) { + } + std::cerr << "Current saddle is of size " << zSaddle.squaredNorm() << "." << std::endl; + } + + ComplexVector zSaddlePrev = ComplexVector::Zero(N); + while (δ < (zSaddle - zSaddlePrev).norm()) { // Until we find two saddles sufficiently close... - std::tie(std::ignore, z) = langevin(J, z, T, γ, M, d, r.engine()); + std::tie(std::ignore, z) = metropolis(J, z, energyNormGrad, T, γ, M, d, r.engine()); try { ComplexVector zSaddleNext = findSaddle(J, z, ε); if (Δ < (zSaddleNext - zSaddle).norm()) { // Ensure we are finding distinct saddles. |