pub struct QLearner { /* private fields */ }Expand description
A simple reinforcement learning framework that can be used to learn optimal policies for Markov decision processes using Q-learning. Q-learning is a model-free reinforcement learning algorithm that learns an optimal action-value function from experience by repeatedly updating estimates of the Q-value of state-action pairs.
Implementations§
Source§impl QLearner
impl QLearner
Sourcepub fn update(&mut self, state: u64, action: u32, reward: f64)
pub fn update(&mut self, state: u64, action: u32, reward: f64)
Updates Q-value for a state-action pair based on received reward.
§Arguments
state- An integer representing the state.action- An integer representing the action.reward- A number representing the reward received for the action in the state.
Sourcepub fn get_best_action(&mut self, state: u64) -> i32
pub fn get_best_action(&mut self, state: u64) -> i32
Sourcepub fn visit_matrix(&mut self, handler: Box<dyn FnMut(u64, u32, f64)>)
pub fn visit_matrix(&mut self, handler: Box<dyn FnMut(u64, u32, f64)>)
Visits all state-action pairs and calls the provided handler function for each pair.
§Arguments
handler- A function that is called for each state-action pair.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QLearner
impl RefUnwindSafe for QLearner
impl Send for QLearner
impl Sync for QLearner
impl Unpin for QLearner
impl UnwindSafe for QLearner
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
Mutably borrows from an owned value. Read more