diff options
Diffstat (limited to 'langevin.cpp')
-rw-r--r-- | langevin.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/langevin.cpp b/langevin.cpp index e5ed0b8..fa737cf 100644 --- a/langevin.cpp +++ b/langevin.cpp @@ -31,7 +31,7 @@ Vector randomVector(unsigned N, Distribution d, Generator& r) { return z; } -std::tuple<double, Vector> gradientDescent(const Tensor& J, const Vector& z0, double γ0, double ε) { +std::tuple<double, Vector> gradientDescent(const Tensor& J, const Vector& z0, double ε, double γ0 = 1, double δγ = 2) { Vector z = z0; double W; @@ -53,7 +53,7 @@ std::tuple<double, Vector> gradientDescent(const Tensor& J, const Vector& z0, do dW = dWNew; γ = γ0; } else { // Otherwise, shrink the step and try again. - γ *= 0.5; + γ /= δγ; } if (γ < 1e-15) { @@ -65,7 +65,7 @@ std::tuple<double, Vector> gradientDescent(const Tensor& J, const Vector& z0, do return {W, z}; } -Vector findSaddle(const Tensor& J, const Vector& z0, double ε, double δW, double γ0) { +Vector findSaddle(const Tensor& J, const Vector& z0, double ε, double δW = 2, double γ0 = 1, double δγ = 2) { double W; std::tie(W, std::ignore) = WdW(J, z0); @@ -91,7 +91,7 @@ Vector findSaddle(const Tensor& J, const Vector& z0, double ε, double δW, doub z = zNew; W = WNew; } else { // Otherwise, do gradient descent until W is a factor δW smaller. - std::tie(W, z) = gradientDescent(J, z, γ0, W / δW); + std::tie(W, z) = gradientDescent(J, z, W / δW, γ0, δγ); ζ = euclideanToStereographic(z); } @@ -186,13 +186,13 @@ int main(int argc, char* argv[]) { Tensor J = generateCouplings<Scalar, PSPIN_P>(N, complex_normal_distribution<>(0, σ, κ), r.engine()); Vector z0 = normalize(randomVector(N, complex_normal_distribution<>(0, 1, 0), r.engine())); - Vector zSaddle = findSaddle(J, z0, ε, δ, γ); + Vector zSaddle = findSaddle(J, z0, ε); double W; Vector z = zSaddle; for (unsigned i = 0; i < n; i++) { std::tie(W, z) = langevin(J, z, T, γ, M, r); - Vector zNewSaddle = findSaddle(J, z, ε, δ, γ); + Vector zNewSaddle = findSaddle(J, z, ε); Scalar H; Matrix ddH; std::tie(H, std::ignore, ddH) = hamGradHess(J, zNewSaddle); |