diff options
| author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-04-19 17:15:40 -0300 | 
|---|---|---|
| committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-04-19 17:15:40 -0300 | 
| commit | 2dbddea11fd7ba06bd8cee7e7e80941eea964e7a (patch) | |
| tree | c2789fe19b81f5fc5342d3be17129e4a5a7e61c5 | |
| parent | ebbd988e3a9e7f55722afd0aa9c35985fb365d7b (diff) | |
| download | code-2dbddea11fd7ba06bd8cee7e7e80941eea964e7a.tar.gz code-2dbddea11fd7ba06bd8cee7e7e80941eea964e7a.tar.bz2 code-2dbddea11fd7ba06bd8cee7e7e80941eea964e7a.zip | |
More straightforward adjustment of step size
| -rw-r--r-- | log-fourier_integrator.cpp | 28 | 
1 files changed, 7 insertions, 21 deletions
| diff --git a/log-fourier_integrator.cpp b/log-fourier_integrator.cpp index cf26fea..44f3b86 100644 --- a/log-fourier_integrator.cpp +++ b/log-fourier_integrator.cpp @@ -92,7 +92,6 @@ int main(int argc, char* argv[]) {      while (true) {        Real ΔC = 100;        Real ΔC₀ = 100; -      unsigned it = 0;        while (ΔC > ε) {          std::vector<Real> dfC(N);          std::vector<Real> RddfC(N); @@ -131,16 +130,9 @@ int main(int argc, char* argv[]) {          if (ΔC < ΔC₀) {            ΔC₀ = ΔC; -          it = 0;            γ = std::min(1.001 * γ, 1.0);          } else { -          it++; -        } - -        if (it > 100) {            γ = std::max(0.5 * γ, 1e-3); -          it = 0; -          ΔC₀ = ΔC;          }          std::cerr << β << " " << μ << " " << ΔC << " " << γ; @@ -150,20 +142,15 @@ int main(int argc, char* argv[]) {          break;        }        if (μ₁ == 0 || μ₂ == 0) { -        if (Cₜ[0] > 1) { -          if (μ₁ == 0) { -            /* We found a lower bound */ -            μ₁ = μ; -          } -          μ *= 1.01; +        if (Cₜ[0] > 1 && μ₁ == 0) { +          /* We found a lower bound */ +          μ₁ = μ;          } -        if (Cₜ[0] < 1) { -          if (μ₂ == 0) { -            /* We found an upper bound */ -            μ₂ = μ; -          } -          μ /= 1.01; +        if (Cₜ[0] < 1 && μ₂ == 0) { +          /* We found an upper bound */ +          μ₂ = μ;          } +        μ *= Cₜ[0];        } else {          /* Once the bounds are set, we can use bisection */          if (Cₜ[0] > 1) { @@ -193,7 +180,6 @@ int main(int argc, char* argv[]) {      std::cerr << β << " " << μ << " " << Ĉₜ[0].real() << " " << E << " " << γ << std::endl;      β += Δβ; -    μ += Δβ;    }    for (unsigned i = 0; i < N; i++) { | 
