/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/common/root_finding.hh Source File#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
root_finding.hh
Go to the documentation of this file.
258 : 4. * std::numeric_limits<double>::epsilon() * std::max(1., std::max(std::abs(x_lo), std::abs(x_hi)));
263 throw std::runtime_error("BisectionRootFinderTarget: no evaluation of the search interval succeeded");
341 inline double solve_scaling_shift(const double A, const double B, const double d1, const double d2)
343 if (!(std::isfinite(A) && std::isfinite(B) && std::isfinite(d1) && std::isfinite(d2))) return NAN;
502 ScalingRootFinder(FUN_NO_RESIDUAL f, const double target, const double rel_tol = 1e-3, const uint max_iter = 40)
576 double get_x_critical() const { return model_valid ? model_x_c : (divergent_valid ? divergent_x_c : NAN); }
591 uint total = 0, expand = 0, model_obs = 0, model_mixed = 0, approach = 0, model_residual = 0, secant = 0,
697 inline void ScalingRootFinder::record(const double x, const bool ok, const double obs, const double residual)
718 !have_success || (by_magnitude ? obs < best_obs : std::abs(obs - target) < std::abs(best_obs - target));
803 std::sort(pts.begin(), pts.end(), [](const auto &a, const auto &b) { return a.first > b.first; });
890 const double window = (obs_window > 0.) ? obs_window * target : std::numeric_limits<double>::infinity();
953 cand = std::min(std::max(cand, x_lo_soft + endpoint_standoff * w), x_hi - endpoint_standoff * w);
984 if (!(target >= 0.)) throw std::runtime_error("ScalingRootFinder: target must be non-negative");
1009 if (have_success && std::isfinite(best_obs) && std::abs(best_obs - target) <= rel_tol * target &&
1026 spdlog::warn("ScalingRootFinder: bracket collapsed to [{:.12e}, {:.12e}] after {} evaluations "
1036 const double y1 = S[S.size() - 1].second, y2 = S[S.size() - 2].second, y3 = S[S.size() - 3].second;
1045 if (!have_success) throw std::runtime_error("ScalingRootFinder: no evaluation of the search interval succeeded");
AbstractRootFinder(const FUN_ARR &f, const double abs_tol=1e-4, const int max_iter=1000)
Definition root_finding.hh:58
AbstractRootFinder(const FUN &f, const double abs_tol=1e-4, const int max_iter=1000)
Definition root_finding.hh:53
std::function< bool(const std::array< double, 1 > &)> FUN_ARR
Definition root_finding.hh:50
virtual std::array< double, 1 > search_impl()=0
std::function< bool(const double)> FUN
Definition root_finding.hh:49
void set_max_iter(const uint max_iter)
Definition root_finding.hh:65
void set_abs_tol(const double abs_tol)
Definition root_finding.hh:63
Definition root_finding.hh:17
void set_abs_tol(const double abs_tol)
Definition root_finding.hh:27
virtual std::array< double, dim > search_impl()=0
void set_max_iter(const uint max_iter)
Definition root_finding.hh:29
std::function< bool(const std::array< double, dim > &)> FUN
Definition root_finding.hh:19
AbstractRootFinder(const FUN &f, const double abs_tol=1e-4, const int max_iter=1000)
Definition root_finding.hh:22
Bisection search which converges a target value rather than the search variable.
Definition root_finding.hh:173
void set_next_x(const std::function< double(double, double)> &next_x)
Definition root_finding.hh:198
void set_abs_tol(const double abs_tol)
Definition root_finding.hh:185
BisectionRootFinderTarget(FUN f, const double abs_tol=1e-4, const int max_iter=1000)
Definition root_finding.hh:180
void set_bounds(const double x_min, const double x_max)
Definition root_finding.hh:192
double get_target() const
Target value belonging to the point returned by search(). NaN before search() ran.
Definition root_finding.hh:211
std::function< bool(const double, double &)> FUN
Definition root_finding.hh:175
void set_max_iter(const uint max_iter)
Definition root_finding.hh:187
double x_collapse_tol
Definition root_finding.hh:284
bool converged() const
Whether the last search() met the target tolerance. False if it stopped early because the bracket col...
Definition root_finding.hh:217
void set_x_max(const double x_max)
Definition root_finding.hh:190
std::function< double(double, double)> next_x
Definition root_finding.hh:289
void set_x_min(const double x_min)
Definition root_finding.hh:189
void set_x_collapse_tol(const double x_collapse_tol)
Width of the x-bracket below which the search gives up. Zero (the default) selects an automatic,...
Definition root_finding.hh:204
Definition root_finding.hh:82
BisectionRootFinder(const FUN &f, const double abs_tol=1e-4, const int max_iter=1000)
Definition root_finding.hh:84
void set_x_max(const double x_max)
Definition root_finding.hh:90
void set_bounds(const double x_min, const double x_max)
Definition root_finding.hh:92
void set_x_min(const double x_min)
Definition root_finding.hh:89
std::function< double(double, double)> next_x
Definition root_finding.hh:129
void set_next_x(const std::function< double(double, double)> &next_x)
Definition root_finding.hh:98
std::array< double, 1 > search_impl() override
Definition root_finding.hh:101
Bracketed root find accelerated by the critical scaling of the observable.
Definition root_finding.hh:477
void set_bounds(const double x_lo, const double x_hi)
Definition root_finding.hh:513
bool bounds_are_hypotheses
Definition root_finding.hh:645
void record(double x, bool ok, double obs, double residual)
Record a probe outcome and update the bracket.
Definition root_finding.hh:697
ScalingRootFinder(FUN_NO_RESIDUAL f, const double target, const double rel_tol=1e-3, const uint max_iter=40)
Definition root_finding.hh:502
void set_expansion_factor(const double rho)
Definition root_finding.hh:519
void set_x_rel_floor(const double v)
Bracket width, relative to the magnitude of the bounds, below which the search gives up.
Definition root_finding.hh:535
const std::vector< std::pair< double, double > > & successes() const
Definition root_finding.hh:587
std::vector< std::pair< double, double > > F
(x, residual) for every informative failure
Definition root_finding.hh:672
void set_exponent_bounds(const double lo, const double hi)
Definition root_finding.hh:549
void set_approach_factor(const double v)
Fraction of the remaining distance to the critical point kept per approach step.
Definition root_finding.hh:565
void set_bounds_are_hypotheses(const bool v)
Definition root_finding.hh:518
void set_expansion_max_iter(const uint n)
Definition root_finding.hh:520
static std::array< std::size_t, 3 > select_triple(const std::size_t)
The three candidates closest to criticality, out of n sorted by distance to it.
Definition root_finding.hh:625
double extrapolate(const double x_c) const
x at which the model predicts obs == effective_target(), given a critical point.
Definition root_finding.hh:610
double get_x_critical() const
Definition root_finding.hh:576
void set_residual_window(const double v)
Definition root_finding.hh:548
void set_acceptance(const Acceptance a)
Definition root_finding.hh:529
void seed_exponent(const double beta)
Definition root_finding.hh:568
void set_max_iter(const uint v)
Definition root_finding.hh:536
void fit_convergent()
Refit from the three convergent points closest to criticality (smallest obs).
Definition root_finding.hh:761
double effective_target() const
Definition root_finding.hh:603
void set_rel_tol(const double v)
Definition root_finding.hh:525
double bracket_width() const
Live bracket width; infinite until both sides are known.
Definition root_finding.hh:585
void set_aim_fraction(const double v)
Definition root_finding.hh:533
double get_x_extrapolated() const
Model extrapolation of the target point. NaN when no model was ever trusted.
Definition root_finding.hh:581
std::function< bool(const double, double &, double &)> FUN
Definition root_finding.hh:492
void fit_divergent()
Refit from the three divergent points closest to criticality (largest residual).
Definition root_finding.hh:795
void set_obs_window(const double v)
Fit only points with obs <= window * target. Ignored when target == 0.
Definition root_finding.hh:545
void set_one_sided(const bool v)
Definition root_finding.hh:528
const std::vector< std::pair< double, double > > & failures() const
Definition root_finding.hh:588
std::vector< std::pair< double, double > > S
(x, obs) for every finite evaluation
Definition root_finding.hh:671
Acceptance
What counts as an answer.
Definition root_finding.hh:489
@ BelowTarget
ScalingRootFinder(FUN f, const double target, const double rel_tol=1e-3, const uint max_iter=40)
Definition root_finding.hh:497
void set_theta_bounds(const double lo, const double hi)
Definition root_finding.hh:557
void set_endpoint_standoff(const double v)
Fraction of the bracket width kept clear of either endpoint when clamping a proposal.
Definition root_finding.hh:563
std::function< bool(const double, double &)> FUN_NO_RESIDUAL
Compatibility shape matching BisectionRootFinderTarget. Disables the divergent-branch model.
Definition root_finding.hh:494
double solve_scaling_shift(const double A, const double B, const double d1, const double d2)
Solve the three-point power-law condition for the shift .
Definition root_finding.hh:341
ScalingFit fit_power_law_3(std::array< double, 3 > x, std::array< double, 3 > y)
Three-point power-law fit. Points need not be pre-sorted.
Definition root_finding.hh:415
Definition complex_math.hh:10
Definition root_finding.hh:590
Generated by