Skip to content

Commit

Permalink
Rename Var::reward to activity
Browse files Browse the repository at this point in the history
  • Loading branch information
shnarazk committed Feb 6, 2025
1 parent d075735 commit 3a01173
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/assign/learning_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ impl ActivityIF<VarId> for AssignStack {
#[inline]
fn activity(&self, vi: VarId) -> f64 {
// self.var[vi].reward
VarRef(vi).reward()
VarRef(vi).activity()
}
// fn activity_slow(&self, vi: VarId) -> f64 {
// self.var[vi].reward_ema.get()
// }
fn set_activity(&mut self, vi: VarId, val: f64) {
// self.var[vi].reward = val;
VarRef(vi).set_reward(val);
VarRef(vi).set_activity(val);
}
fn reward_at_analysis(&mut self, vi: VarId) {
// self.var[vi].turn_on(FlagVar::USED);
Expand Down
4 changes: 2 additions & 2 deletions src/assign/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl VarSelectIF for AssignStack {
if VarRef(*vi).is(FlagVar::PHASE) != *b {
num_flipped += 1;
VarRef(*vi).set_flag(FlagVar::PHASE, *b);
VarRef(*vi).set_reward(
VarRef(*vi).reward() * self.activity_decay + self.activity_anti_decay,
VarRef(*vi).set_activity(
VarRef(*vi).activity() * self.activity_decay + self.activity_anti_decay,
);
self.update_heap(*vi);
}
Expand Down
4 changes: 2 additions & 2 deletions src/assign/trail_saving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl TrailSavingIF for AssignStack {
self.clear_saved_trail();
if 2 <= dl {
let lim2 = self.trail_lim[dl - 2];
let activity_threshold = VarRef(self.trail[lim2].vi()).reward() /* self.var[self.trail[lim2].vi()].reward */;
let activity_threshold = VarRef(self.trail[lim2].vi()).activity() /* self.var[self.trail[lim2].vi()].reward */;
for i in (lim..lim2).rev() {
let l = self.trail[i];
let vi = l.vi();
Expand All @@ -42,7 +42,7 @@ impl TrailSavingIF for AssignStack {
// self.var[vi].reason_saved = self.var[vi].reason;
VarRef(vi).set_reason_saved(VarRef(vi).reason());
self.reward_at_unassign(vi);
if activity_threshold <= VarRef(vi).reward()
if activity_threshold <= VarRef(vi).activity()
/* self.var[vi].reward */
{
self.insert_heap(vi);
Expand Down
12 changes: 6 additions & 6 deletions src/types/var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Var {
/// the `Flag`s (8 bits)
pub(crate) flags: FlagVar,
/// a dynamic evaluation criterion like EVSIDS or ACID.
pub(crate) reward: f64,
pub(crate) activity: f64,
// reward_ema: Ema2,
#[cfg(feature = "boundary_check")]
pub propagated_at: usize,
Expand All @@ -39,7 +39,7 @@ impl Default for Var {
#[cfg(feature = "trail_saving")]
reason_saved: AssignReason::None,
flags: FlagVar::empty(),
reward: 0.0,
activity: 0.0,
// reward_ema: Ema2::new(200).with_slow(4_000),
#[cfg(feature = "boundary_check")]
propagated_at: 0,
Expand Down Expand Up @@ -71,7 +71,7 @@ impl Var {
.collect::<Vec<_>>()
}
pub fn activity(&self) -> f64 {
self.reward
self.activity
}
pub fn update_activity(&mut self, decay: f64, reward: f64) -> f64 {
// Note: why the condition can be broken.
Expand All @@ -82,13 +82,13 @@ impl Var {
// 1. restart
// 1. cancel_until -> reward_at_unassign -> assertion failed
//
self.reward *= decay;
self.activity *= decay;
if self.is(FlagVar::USED) {
self.reward += reward;
self.activity += reward;
self.turn_off(FlagVar::USED);
}
// self.reward_ema.update(self.reward);
self.reward
self.activity
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl VarActivityManager {
}
pub fn add_var(vi: VarId) {
unsafe {
VAR_HEAP.push(OrderedProxy::new(vi, VarRef(vi).reward()));
VAR_HEAP.push(OrderedProxy::new(vi, VarRef(vi).activity()));
}
}
pub fn remove_var(vi: VarId) {
Expand Down
14 changes: 7 additions & 7 deletions src/var_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub trait VarRefIF {
fn set_reason(&self, value: AssignReason);
fn reason_saved(&self) -> AssignReason;
fn set_reason_saved(&self, value: AssignReason);
fn reward(&self) -> f64;
fn set_reward(&self, value: f64);
fn activity(&self) -> f64;
fn set_activity(&self, value: f64);
fn update_activity(&self, decay: f64, anti_decay: f64);
fn is(&self, f: FlagVar) -> bool;
fn turn_on(&self, f: FlagVar);
Expand Down Expand Up @@ -57,7 +57,7 @@ impl VarRef {
}
pub fn rescale_activity(scaling: f64) {
for i in VarRef::var_id_iter() {
VarRef(i).set_reward(VarRef(i).reward() * scaling);
VarRef(i).set_activity(VarRef(i).activity() * scaling);
}
}
}
Expand Down Expand Up @@ -104,13 +104,13 @@ impl VarRefIF for VarRef {
}
}
#[inline]
fn reward(&self) -> f64 {
unsafe { VAR_VECTOR.get_unchecked(self.0).reward }
fn activity(&self) -> f64 {
unsafe { VAR_VECTOR.get_unchecked(self.0).activity }
}
#[inline]
fn set_reward(&self, value: f64) {
fn set_activity(&self, value: f64) {
unsafe {
VAR_VECTOR.get_unchecked_mut(self.0).reward = value;
VAR_VECTOR.get_unchecked_mut(self.0).activity = value;
}
}
#[inline]
Expand Down

0 comments on commit 3a01173

Please sign in to comment.