Struct VsidsHeap

Source
pub struct VsidsHeap { /* private fields */ }
Expand description

A VSIDS (Variable State Independent Decaying Sum) implementation using a binary heap.

This strategy maintains an activity score for each literal. Variables involved in recent conflicts get their scores “bumped”. Periodically, all scores “decay”. The BinaryHeap is used to efficiently find the unassigned literal with the highest activity score. This implementation aims for O(log N) pick operations on average, where N is the number of variables.

Trait Implementations§

Source§

impl Clone for VsidsHeap

Source§

fn clone(&self) -> VsidsHeap

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VsidsHeap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Index<usize> for VsidsHeap

Index trait implementation for the VSIDS heap. Allows for indexing into the scores vector using a usize that typically corresponds to Literal::index().

§Safety

This implementation uses get_unchecked for performance

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for VsidsHeap

IndexMut trait implementation for the VSIDS heap. Allows for mutable indexing into the scores vector using a usize that typically corresponds to Literal::index().

§Safety

Similar to the Index implementation, this uses get_unchecked_mut.

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<L: Literal> VariableSelection<L> for VsidsHeap

VariableSelection trait implementation for the VSIDS heap.

Source§

fn new<C: AsRef<[L]>>(num_vars: usize, _: &[L], _: &[C]) -> Self

Creates a new instance of the VsidsHeap strategy.

Initialises scores for all possible literals (2 * num_vars) to zero. The activity_inc is initialised to 1.0. The heap is populated with initial zero scores for all literals.

Source§

fn pick<A: Assignment>(&mut self, assignment: &A) -> Option<L>

Picks an unassigned variable with the highest activity score.

It repeatedly pops from the heap until it finds a ScoreEntry whose corresponding variable is unassigned and whose score matches the current score in the scores vector (to filter out stale entries).

The complexity is typically O(log N) for heap pop, but can be higher if many stale entries need to be processed.

Source§

fn bumps<T: IntoIterator<Item = L>>(&mut self, vars: T)

Bumps the activity scores of the specified literals.

For each literal in vars, its score is incremented by activity_inc, and the heap is updated accordingly via bump_internal.

Source§

fn decay(&mut self, decay: f64)

Decays the activity scores.

In this VSIDS implementation, scores are not directly decayed. Instead, activity_inc is divided by the decay factor (typically 0 < decay < 1, e.g. 0.95, so activity_inc effectively increases). This gives more weight to variables involved in more recent conflicts.

If activity_inc exceeds VSIDS_RESCALE_THRESHOLD, all scores and activity_inc are rescaled by multiplying with VSIDS_RESCALE_FACTOR to prevent overflow and maintain precision. This rescaling step involves rebuilding the heap, which can be an O(N) operation.

Source§

fn decisions(&self) -> usize

Returns the total number of decisions made by this strategy instance.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.