Skip to content

Commit

Permalink
Remove Ewa, Implement some missing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
shnarazk committed Sep 22, 2024
1 parent 8525b77 commit ad2e7af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/assign/ema.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
use crate::types::*;

const ASG_EWA_LEN: usize = 16;
const ASG_EWA_SLOW: usize = 8192;
const ASG_EMA_LEN: usize = 16;
const ASG_EMA_SLOW: usize = 8192;

/// An assignment history used for blocking restart.
#[derive(Clone, Debug)]
pub struct ProgressASG {
ema: Ewa2<ASG_EWA_LEN>,
ema: Ema2,
}

impl Default for ProgressASG {
fn default() -> ProgressASG {
ProgressASG {
ema: Ewa2::<ASG_EWA_LEN>::new(0.0),
ema: Ema2::new(ASG_EMA_LEN).with_slow(ASG_EMA_SLOW),
}
}
}

impl Instantiate for ProgressASG {
fn instantiate(_config: &Config, _cnf: &CNFDescription) -> Self {
ProgressASG {
ema: Ewa2::new(0.0).with_slow(ASG_EWA_SLOW),
ema: Ema2::new(ASG_EMA_LEN).with_slow(ASG_EMA_SLOW),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/cdb/ema.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use crate::types::*;

const LBD_EWA_LEN: usize = 16;
const LBD_EWA_SLOW: usize = 8192;
const LBD_EMA_LEN: usize = 16;
const LBD_EMA_SLOW: usize = 8192;

/// An EMA of learnt clauses' LBD, used for forcing restart.
#[derive(Clone, Debug)]
pub struct ProgressLBD {
ema: Ewa2<LBD_EWA_LEN>,
ema: Ema2,
num: usize,
sum: usize,
}

impl Default for ProgressLBD {
fn default() -> ProgressLBD {
ProgressLBD {
ema: Ewa2::new(0.0),
ema: Ema2::new(LBD_EMA_LEN).with_slow(LBD_EMA_SLOW),
num: 0,
sum: 0,
}
Expand All @@ -24,7 +24,7 @@ impl Default for ProgressLBD {
impl Instantiate for ProgressLBD {
fn instantiate(_config: &Config, _: &CNFDescription) -> Self {
ProgressLBD {
ema: Ewa2::new(0.0).with_slow(LBD_EWA_SLOW),
ema: Ema2::new(LBD_EMA_LEN).with_slow(LBD_EMA_SLOW),
..ProgressLBD::default()
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/primitive/ema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ impl EmaIF for Ema {
}

impl EmaMutIF for Ema {
fn reset_to(&mut self, val: f64) {
self.val.fast = val;
}
fn reset_fast(&mut self) {
self.val.fast = 0.0;
}
type Input = f64;
#[cfg(not(feature = "EMA_calibration"))]
fn update(&mut self, x: Self::Input) {
Expand Down Expand Up @@ -197,6 +203,7 @@ impl EmaMutIF for Ema2 {
}
fn reset_to(&mut self, val: f64) {
self.ema.fast = val;
self.ema.slow = val;
}
#[cfg(not(feature = "EMA_calibration"))]
fn reset_fast(&mut self) {
Expand Down Expand Up @@ -303,6 +310,7 @@ impl EmaSU {
}
}

/*
/// Equally-Weighted-Average, namely, Average
#[derive(Clone, Debug)]
pub struct Ewa<const N: usize = 32> {
Expand Down Expand Up @@ -386,6 +394,7 @@ impl<const N: usize> EmaMutIF for Ewa2<N> {
}
fn reset_to(&mut self, val: f64) {
self.ema.fast = val;
self.ema.slow = val;
}
#[cfg(not(feature = "EMA_calibration"))]
fn reset_fast(&mut self) {
Expand Down Expand Up @@ -431,3 +440,4 @@ impl<const N: usize> Ewa2<N> {
self
}
}
*/

0 comments on commit ad2e7af

Please sign in to comment.