pub struct RewardCalculator { /* private fields */ }Expand description
Calculator for episode reward scores
Implementations§
Source§impl RewardCalculator
impl RewardCalculator
Sourcepub fn with_weights(duration_weight: f32, step_count_weight: f32) -> Self
pub fn with_weights(duration_weight: f32, step_count_weight: f32) -> Self
Create a calculator with custom weights
Sourcepub fn calculate(&self, episode: &Episode) -> RewardScore
pub fn calculate(&self, episode: &Episode) -> RewardScore
Calculate reward score for an episode
Sourcepub fn calculate_adoption_bonus(
&self,
applied_pattern_ids: &[String],
outcome_success: bool,
) -> f32
pub fn calculate_adoption_bonus( &self, applied_pattern_ids: &[String], outcome_success: bool, ) -> f32
Calculate adoption bonus for patterns that were recommended AND applied AND succeeded.
This bonus rewards episodes where the agent successfully applied recommended patterns. The bonus is proportional to the number of successfully adopted patterns.
§Arguments
applied_pattern_ids- Pattern IDs that were actually appliedoutcome_success- Whether the episode outcome was successful
§Returns
Bonus value between 0.0 and 0.3 (max 30% bonus for 3+ successful adoptions)
§Example
use do_memory_core::reward::RewardCalculator;
let calculator = RewardCalculator::new();
// 2 patterns applied successfully
let bonus = calculator.calculate_adoption_bonus(
&["p1".to_string(), "p2".to_string()],
true
);
assert!(bonus > 0.0);
// No bonus for failed outcome
let no_bonus = calculator.calculate_adoption_bonus(
&["p1".to_string()],
false
);
assert_eq!(no_bonus, 0.0);Trait Implementations§
Source§impl Clone for RewardCalculator
impl Clone for RewardCalculator
Source§fn clone(&self) -> RewardCalculator
fn clone(&self) -> RewardCalculator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RewardCalculator
impl RefUnwindSafe for RewardCalculator
impl Send for RewardCalculator
impl Sync for RewardCalculator
impl Unpin for RewardCalculator
impl UnsafeUnpin for RewardCalculator
impl UnwindSafe for RewardCalculator
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> 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>
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<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.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.