Struct PerConfig

Source
pub struct PerConfig {
    pub alpha: f32,
    pub beta_0: f32,
    pub beta_final: f32,
    pub n_opts_final: usize,
    pub normalize: WeightNormalizer,
}
Expand description

Configuration for Prioritized Experience Replay (PER).

This structure defines the parameters for prioritized sampling in the replay buffer. It controls how transitions are sampled based on their importance and how importance weights are calculated and normalized.

§Fields

  • alpha - Controls the degree of prioritization (0 = uniform sampling)
  • beta_0 - Initial value for importance sampling weights
  • beta_final - Final value for importance sampling weights
  • n_opts_final - Number of optimization steps to reach beta_final
  • normalize - Method for normalizing importance weights

§Examples

use border_core::generic_replay_buffer::{PerConfig, WeightNormalizer};

let config = PerConfig::default()
    .alpha(0.6)
    .beta_0(0.4)
    .beta_final(1.0)
    .n_opts_final(500_000)
    .normalize(WeightNormalizer::All);

Fields§

§alpha: f32

Exponent for prioritization. Higher values increase the bias towards high-priority transitions. A value of 0 results in uniform sampling.

§beta_0: f32

Initial value of the importance sampling exponent. Lower values reduce the impact of importance sampling weights.

§beta_final: f32

Final value of the importance sampling exponent. Typically set to 1.0 to fully compensate for the non-uniform sampling.

§n_opts_final: usize

Number of optimization steps after which beta reaches its final value. This allows for a gradual increase in the impact of importance sampling.

§normalize: WeightNormalizer

Method for normalizing importance sampling weights. Controls how the weights are scaled to prevent numerical instability.

Implementations§

Source§

impl PerConfig

Source

pub fn alpha(self, alpha: f32) -> Self

Sets the prioritization exponent alpha.

§Arguments
  • alpha - The new value for the prioritization exponent
§Returns

The modified configuration

Source

pub fn beta_0(self, beta_0: f32) -> Self

Sets the initial importance sampling exponent beta_0.

§Arguments
  • beta_0 - The new initial value for the importance sampling exponent
§Returns

The modified configuration

Source

pub fn beta_final(self, beta_final: f32) -> Self

Sets the final importance sampling exponent beta_final.

§Arguments
  • beta_final - The new final value for the importance sampling exponent
§Returns

The modified configuration

Source

pub fn n_opts_final(self, n_opts_final: usize) -> Self

Sets the number of optimization steps to reach the final beta value.

§Arguments
  • n_opts_final - The new number of optimization steps
§Returns

The modified configuration

Source

pub fn normalize(self, normalize: WeightNormalizer) -> Self

Sets the method for normalizing importance weights.

§Arguments
  • normalize - The new normalization method
§Returns

The modified configuration

Trait Implementations§

Source§

impl Clone for PerConfig

Source§

fn clone(&self) -> PerConfig

Returns a copy 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 PerConfig

Source§

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

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

impl Default for PerConfig

Source§

fn default() -> Self

Creates a default PER configuration with commonly used values:

  • alpha = 0.6 (moderate prioritization)
  • beta_0 = 0.4 (initial importance sampling)
  • beta_final = 1.0 (full compensation)
  • n_opts_final = 500_000 (gradual increase)
  • normalize = All (normalize all weights)
Source§

impl<'de> Deserialize<'de> for PerConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PerConfig

Source§

fn eq(&self, other: &PerConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PerConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PerConfig

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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,