pub struct NeuralRLAgent {
pub config: AdvancedConfig,
pub learning_rate: f64,
pub strategy: ExplorationStrategy,
/* private fields */
}Expand description
Adaptive (bandit-style) reinforcement-learning agent for algorithm/strategy selection.
Despite the historical “Neural” name (kept for API stability), this is a
classical multi-armed-bandit reinforcement learner – epsilon-greedy,
UCB, an approximate Thompson-sampling-style rule, or adaptive-uncertainty
exploration, per the configured ExplorationStrategy – not a deep
neural network. It genuinely tracks per-arm reward statistics
((pull_count, mean_reward)) and adapts its choices using real
randomness (scirs2_core::random::rng); nothing here is a fixed
placeholder. See AdvancedProcessor::execute_adaptive for the
intended usage (choosing among several candidate implementations of the
same operation).
Fields§
§config: AdvancedConfigAgent configuration
learning_rate: f64Learning rate: how quickly record_reward updates track new
observations. 0.0 means “plain running average of every reward
ever observed”; a positive rate makes it an exponential moving
average that favors recent observations.
strategy: ExplorationStrategyExploration strategy used by Self::select_arm
Implementations§
Source§impl NeuralRLAgent
impl NeuralRLAgent
Sourcepub fn new(config: AdvancedConfig, strategy: ExplorationStrategy) -> Self
pub fn new(config: AdvancedConfig, strategy: ExplorationStrategy) -> Self
Creates a new agent using the given exploration strategy;
config.learning_rate seeds Self::learning_rate.
Sourcepub fn arm_stats(&self, arm: usize) -> Option<(u64, f64)>
pub fn arm_stats(&self, arm: usize) -> Option<(u64, f64)>
The current (pull_count, mean_reward) estimate for arm, or
None if it has never been selected.
Sourcepub fn select_arm(&mut self, n_arms: usize) -> usize
pub fn select_arm(&mut self, n_arms: usize) -> usize
Selects one of n_arms candidate actions according to the configured
ExplorationStrategy and this agent’s accumulated reward history.
Any arm never pulled before is always tried first (standard bandit
warm-up), before the configured strategy takes over.
Sourcepub fn record_reward(&mut self, arm: usize, reward: f64)
pub fn record_reward(&mut self, arm: usize, reward: f64)
Records an observed reward for arm, updating its running
statistics (growing the tracked arm count if needed).
Trait Implementations§
Source§impl Clone for NeuralRLAgent
impl Clone for NeuralRLAgent
Source§fn clone(&self) -> NeuralRLAgent
fn clone(&self) -> NeuralRLAgent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NeuralRLAgent
impl Debug for NeuralRLAgent
Auto Trait Implementations§
impl Freeze for NeuralRLAgent
impl RefUnwindSafe for NeuralRLAgent
impl Send for NeuralRLAgent
impl Sync for NeuralRLAgent
impl Unpin for NeuralRLAgent
impl UnsafeUnpin for NeuralRLAgent
impl UnwindSafe for NeuralRLAgent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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