ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
CaDiCaL::EMA Struct Reference

#include <ema.hpp>

Public Member Functions

 EMA ()
 
 EMA (double a)
 
 operator double () const
 
void update (Internal *, double y, const char *name)
 

Public Attributes

double value
 
double biased
 
double alpha
 
double beta
 
double exp
 

Detailed Description

Definition at line 18 of file ema.hpp.

Constructor & Destructor Documentation

◆ EMA() [1/2]

CaDiCaL::EMA::EMA ( )
inline

Definition at line 29 of file ema.hpp.

30 :
31#ifdef LOGGING
32 updated (0),
33#endif
34 value (0), biased (0), alpha (0), beta (0), exp (0) {
35 }
double value
Definition ema.hpp:23
double alpha
Definition ema.hpp:25
double biased
Definition ema.hpp:24
double beta
Definition ema.hpp:26
double exp
Definition ema.hpp:27

◆ EMA() [2/2]

CaDiCaL::EMA::EMA ( double a)
inline

Definition at line 37 of file ema.hpp.

38 :
39#ifdef LOGGING
40 updated (0),
41#endif
42 value (0), biased (0), alpha (a), beta (1 - a), exp (!!beta) {
43 CADICAL_assert (beta >= 0);
44 }
#define CADICAL_assert(ignore)
Definition global.h:14

Member Function Documentation

◆ operator double()

CaDiCaL::EMA::operator double ( ) const
inline

Definition at line 46 of file ema.hpp.

46{ return value; }

◆ update()

void CaDiCaL::EMA::update ( Internal * internal,
double y,
const char * name )

Definition at line 60 of file cadical_ema.cpp.

60 {
61#ifdef LOGGING
62 updated++;
63 const double old_value = value;
64#endif
65 const double old_biased = biased;
66 const double delta = y - old_biased;
67 const double scaled_delta = alpha * delta;
68 const double new_biased = old_biased + scaled_delta;
69 LOG ("update %" PRIu64 " of biased %s EMA %g with %g (delta %g) "
70 "yields %g (scaled delta %g)",
71 updated, name, old_biased, y, delta, new_biased, scaled_delta);
72 biased = new_biased;
73 const double old_exp = exp;
74 double new_exp, div, new_value;
75 if (old_exp) {
76 new_exp = old_exp * beta;
77 CADICAL_assert (new_exp < 1);
78 exp = new_exp;
79 div = 1 - new_exp;
80 CADICAL_assert (div > 0);
81 new_value = new_biased / div;
82 } else {
83 new_value = new_biased;
84#ifdef LOGGING
85 new_exp = 0;
86 div = 1;
87#endif
88 }
89 value = new_value;
90 LOG ("update %" PRIu64 " of corrected %s EMA %g with %g (delta %g) "
91 "yields %g (exponent %g, divisor %g)",
92 updated, name, old_value, y, delta, new_value, new_exp, div);
93#ifndef LOGGING
94 (void) internal;
95 (void) name;
96#endif
97}
#define LOG(...)
char * name
Definition main.h:24

Member Data Documentation

◆ alpha

double CaDiCaL::EMA::alpha

Definition at line 25 of file ema.hpp.

◆ beta

double CaDiCaL::EMA::beta

Definition at line 26 of file ema.hpp.

◆ biased

double CaDiCaL::EMA::biased

Definition at line 24 of file ema.hpp.

◆ exp

double CaDiCaL::EMA::exp

Definition at line 27 of file ema.hpp.

◆ value

double CaDiCaL::EMA::value

Definition at line 23 of file ema.hpp.


The documentation for this struct was generated from the following files: