From 54416465850a9280a121127e0b5301d97ad13a61 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 8 Nov 2021 23:19:54 +0100 Subject: Removed some unused files. --- dynamics.hpp | 64 ------------------------------------------------------------ 1 file changed, 64 deletions(-) (limited to 'dynamics.hpp') diff --git a/dynamics.hpp b/dynamics.hpp index 21afd30..7d04b1a 100644 --- a/dynamics.hpp +++ b/dynamics.hpp @@ -4,45 +4,7 @@ #include #include -#include - #include "p-spin.hpp" -#include "stereographic.hpp" - -class gradientDescentStallException: public std::exception { - virtual const char* what() const throw() { - return "Gradient descent stalled."; - } -}; - -template -std::tuple> gradientDescent(const Tensor& J, const Vector& z0, Real ε, Real γ0 = 1, Real δγ = 2) { - Vector z = z0; - Real γ = γ0; - - auto [W, dW] = WdW(J, z); - - while (W > ε) { - Vector zNew = normalize(z - γ * dW.conjugate()); - - auto [WNew, dWNew] = WdW(J, zNew); - - if (WNew < W) { // If the step lowered the objective, accept it! - z = zNew; - W = WNew; - dW = dWNew; - γ = γ0; - } else { // Otherwise, shrink the step and try again. - γ /= δγ; - } - - if (γ < 1e-50) { - throw gradientDescentStallException(); - } - } - - return {W, z}; -} template Vector findMinimum(const Tensor& J, const Vector& z0, Real ε) { @@ -98,8 +60,6 @@ Vector findSaddle(const Tensor& J, const Vector& z0, std::tie(std::ignore, dH, ddH) = hamGradHess(J, z); - std::cout << "error : " << g.norm() / z.size() << std::endl; - zz = z.transpose() * z; g = dH - (z.transpose() * dH) * z / (Real)z.size() + z * (zz - (Real)z.size()); M = ddH - (dH * z.transpose() + (z.transpose() * dH) * Matrix::Identity(z.size(), z.size()) + (ddH * z) * z.transpose()) / (Real)z.size() + Matrix::Identity(z.size(), z.size()) * (zz - (Real)z.size()) + 2.0 * z * z.transpose(); @@ -119,30 +79,6 @@ Vector randomVector(unsigned N, Distribution d, Generator& r) { return z; } -template -std::tuple> metropolis(const Tensor& J, const Vector& z0, - std::function&, const Vector&)>& energy, - Real T, Real γ, unsigned N, Distribution d, Generator& r) { - Vector z = z0; - - Real E = energy(J, z); - - std::uniform_real_distribution D(0, 1); - - for (unsigned i = 0; i < N; i++) { - Vector zNew = normalize(z + γ * randomVector(z.size(), d, r)); - - Real ENew = energy(J, zNew); - - if (E - ENew > T * log(D(r))) { - z = zNew; - E = ENew; - } - } - - return {E, z}; -} - template Vector randomMinimum(const Tensor& J, Distribution d, Generator& r, Real ε) { Vector zSaddle; -- cgit v1.2.3-54-g00ecf