LCOV - code coverage report
Current view: top level - app/include/Opt - QuadraticGuessSolver.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2023-08-17 16:45:52 Functions: 0 0 -

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "Opt/SolverWithInitialSolutions.hpp"
       4             : #include "Opt/UnivariateSolver.hpp"
       5             : 
       6             : namespace Opt {
       7             : /**
       8             :  * @brief Solver that guesses the value of the next solution.
       9             :  *
      10             :  * Provides three solutions to the solver. Solutions are calculated as follows:
      11             :  * $s_{n+1} = (1-\alpha) s_n + \alpha x_n$
      12             :  * $s_1 = M * s_n$
      13             :  * $s_2 = s_1 * 10^{-m}$
      14             :  * $s_3 = s_1 * 10^{m}$
      15             :  * where:
      16             :  * - $s_n$ are solution estimates.
      17             :  * - $\alpha$ is the exponential smoothing factor; should be a small value,
      18             :  *   typically 0.1 or 0.2 to prevent excessive jitter.
      19             :  * - $M$ is the multiplicative adjustment factor. This is because a small
      20             :  *   $\alpha$ avoids jitter, but this delays adapting to more recent answers.
      21             :  *   Since we already know where the process is going (e.g., we have an idea
      22             :  *   that the real value is 85% of the estimate), we can adjust the estimation
      23             :  *   by multiplying all solutions with $M$.
      24             :  * - $m$ is the margin.
      25             :  */
      26           0 : class QuadraticGuessSolver: public UnivariateSolver {
      27             :     SolverWithInitialSolutions &solver;
      28             : 
      29             :     Var s;
      30             :     Var alpha;
      31             :     Var multAdjust;
      32             :     Var margin;
      33             :     Var epsilon = 0.1;
      34             : 
      35             :    public:
      36             :     // clang-format off
      37             :     /**
      38             :      * @brief Construct a new Quadratic Solver Guesser object.
      39             :      *
      40             :      * @param initialSolution   Initial solution
      41             :      * @param alpha             Exponential smoothing factor
      42             :      * @param multAdjust        Multiplicative adjustment factor
      43             :      * @param margin            Margin (in logarithmic scale, log10)
      44             :      */
      45             :     QuadraticGuessSolver(
      46             :         SolverWithInitialSolutions &solver,
      47             :         Var initialSolution,
      48             :         Var alpha      = 0.2,
      49             :         Var multAdjust = 1.0,
      50             :         Var margin     = 1.0
      51             :     );
      52             :     // clang-format on
      53             : 
      54             :     virtual void setStopCriteria(Var e);
      55             : 
      56             :     virtual Var solve(Problem p);
      57             : };
      58             : }  // namespace Opt

Generated by: LCOV version 1.14