Skip to main content

OptimizationStrategy

Trait OptimizationStrategy 

Source
pub trait OptimizationStrategy: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn priority(&self) -> u32;
    fn is_applicable(&self, input: &DecisionInput) -> bool;
    fn evaluate<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        input: &'life1 DecisionInput,
        criteria: &'life2 DecisionCriteria,
    ) -> Pin<Box<dyn Future<Output = DecisionResult<Vec<Decision>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn validate<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        decision: &'life1 Decision,
        criteria: &'life2 DecisionCriteria,
    ) -> Pin<Box<dyn Future<Output = DecisionResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn learn<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        decision: &'life1 Decision,
        outcome: &'life2 DecisionOutcome,
    ) -> Pin<Box<dyn Future<Output = DecisionResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_stats(&self) -> Value;
}
Expand description

Trait for optimization strategies

Required Methods§

Source

fn name(&self) -> &str

Get the name of this strategy

Source

fn priority(&self) -> u32

Get the priority of this strategy (higher = more important)

Source

fn is_applicable(&self, input: &DecisionInput) -> bool

Check if this strategy is applicable to the given input

Source

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, input: &'life1 DecisionInput, criteria: &'life2 DecisionCriteria, ) -> Pin<Box<dyn Future<Output = DecisionResult<Vec<Decision>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Evaluate and generate decisions

§Arguments
  • input - Input from the analyzer engine
  • criteria - Decision criteria to use
§Returns

Vector of decisions this strategy recommends

Source

fn validate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, decision: &'life1 Decision, criteria: &'life2 DecisionCriteria, ) -> Pin<Box<dyn Future<Output = DecisionResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Validate a decision before execution

§Arguments
  • decision - The decision to validate
  • criteria - Decision criteria to validate against
§Returns

Ok if valid, Err with reason if invalid

Source

fn learn<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, decision: &'life1 Decision, outcome: &'life2 DecisionOutcome, ) -> Pin<Box<dyn Future<Output = DecisionResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Learn from a decision outcome

§Arguments
  • decision - The original decision
  • outcome - The outcome that was observed
Source

fn get_stats(&self) -> Value

Get strategy-specific statistics

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§