pub struct QLearningOptimizer { /* private fields */ }Expand description
Q-learning agent for circuit optimization
Implementations§
Source§impl QLearningOptimizer
impl QLearningOptimizer
Sourcepub fn new(
learning_rate: f64,
discount_factor: f64,
initial_epsilon: f64,
) -> Self
pub fn new( learning_rate: f64, discount_factor: f64, initial_epsilon: f64, ) -> Self
Create a new Q-learning optimizer
§Arguments
learning_rate- How quickly the agent learns (0.0 to 1.0)discount_factor- How much future rewards matter (0.0 to 1.0)initial_epsilon- Initial exploration rate (0.0 to 1.0)
Sourcepub fn choose_action(
&self,
state: &CircuitState,
available_actions: &[OptimizationAction],
) -> OptimizationAction
pub fn choose_action( &self, state: &CircuitState, available_actions: &[OptimizationAction], ) -> OptimizationAction
Choose action using epsilon-greedy policy
§Arguments
state- Current circuit stateavailable_actions- List of actions that can be taken
Sourcepub fn update_q_value(
&mut self,
state: &CircuitState,
action: OptimizationAction,
reward: f64,
next_state: &CircuitState,
next_actions: &[OptimizationAction],
)
pub fn update_q_value( &mut self, state: &CircuitState, action: OptimizationAction, reward: f64, next_state: &CircuitState, next_actions: &[OptimizationAction], )
Update Q-value based on observed reward
§Arguments
state- Previous stateaction- Action takenreward- Reward receivednext_state- New state after actionnext_actions- Actions available in next state
Sourcepub fn calculate_reward(
&self,
old_state: &CircuitState,
new_state: &CircuitState,
) -> f64
pub fn calculate_reward( &self, old_state: &CircuitState, new_state: &CircuitState, ) -> f64
Calculate reward for a state transition
Reward is based on improvements in circuit metrics:
- Reduced depth (+reward)
- Reduced gate count (+reward)
- Increased fidelity (+reward)
Sourcepub fn finish_episode(&mut self, episode: OptimizationEpisode)
pub fn finish_episode(&mut self, episode: OptimizationEpisode)
Complete an optimization episode
Sourcepub fn get_statistics(&self) -> OptimizationStatistics
pub fn get_statistics(&self) -> OptimizationStatistics
Get optimization statistics
Sourcepub fn save_q_table(&self, path: &str) -> QuantRS2Result<()>
pub fn save_q_table(&self, path: &str) -> QuantRS2Result<()>
Save Q-table to file
Sourcepub fn load_q_table(&mut self, path: &str) -> QuantRS2Result<()>
pub fn load_q_table(&mut self, path: &str) -> QuantRS2Result<()>
Load Q-table from file
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QLearningOptimizer
impl RefUnwindSafe for QLearningOptimizer
impl Send for QLearningOptimizer
impl Sync for QLearningOptimizer
impl Unpin for QLearningOptimizer
impl UnwindSafe for QLearningOptimizer
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
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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.