pub struct InteractiveSession<G>where
G: EvolutionaryGenome,{
pub version: u32,
pub population: Vec<Candidate<G>>,
pub generation: usize,
pub evaluations_requested: usize,
pub responses_received: usize,
pub skipped: usize,
pub aggregator: FitnessAggregator,
pub request_history: Vec<SerializedRequest>,
pub metadata: HashMap<String, String>,
pub next_candidate_id: usize,
}Expand description
Complete state of an interactive evolution session
This struct captures all state needed to pause and resume an interactive evolution session, including population, fitness aggregator state, and session metadata.
Fields§
§version: u32Schema version for forward compatibility
population: Vec<Candidate<G>>Current population with fitness estimates
generation: usizeCurrent generation number
evaluations_requested: usizeTotal evaluation requests made
responses_received: usizeTotal responses received (excluding skips)
skipped: usizeNumber of skipped evaluations
aggregator: FitnessAggregatorFitness aggregator state
request_history: Vec<SerializedRequest>History of evaluation requests (limited to recent history)
metadata: HashMap<String, String>Custom session metadata
next_candidate_id: usizeNext candidate ID to assign
Implementations§
Source§impl<G> InteractiveSession<G>where
G: EvolutionaryGenome,
impl<G> InteractiveSession<G>where
G: EvolutionaryGenome,
Sourcepub fn new(aggregator: FitnessAggregator) -> Self
pub fn new(aggregator: FitnessAggregator) -> Self
Create a new empty session
Sourcepub fn with_population(
population: Vec<Candidate<G>>,
aggregator: FitnessAggregator,
) -> Self
pub fn with_population( population: Vec<Candidate<G>>, aggregator: FitnessAggregator, ) -> Self
Create a new session with initial population
Sourcepub fn next_id(&mut self) -> CandidateId
pub fn next_id(&mut self) -> CandidateId
Get the next candidate ID and increment counter
Sourcepub fn add_candidate(&mut self, genome: G) -> CandidateId
pub fn add_candidate(&mut self, genome: G) -> CandidateId
Add a candidate to the population
Sourcepub fn get_candidate(&self, id: CandidateId) -> Option<&Candidate<G>>
pub fn get_candidate(&self, id: CandidateId) -> Option<&Candidate<G>>
Get a candidate by ID
Sourcepub fn get_candidate_mut(
&mut self,
id: CandidateId,
) -> Option<&mut Candidate<G>>
pub fn get_candidate_mut( &mut self, id: CandidateId, ) -> Option<&mut Candidate<G>>
Get a mutable reference to a candidate by ID
Sourcepub fn unevaluated_candidates(&self) -> Vec<&Candidate<G>>
pub fn unevaluated_candidates(&self) -> Vec<&Candidate<G>>
Get all candidates that haven’t been evaluated
Sourcepub fn ranked_candidates(&self) -> Vec<&Candidate<G>>
pub fn ranked_candidates(&self) -> Vec<&Candidate<G>>
Get candidates sorted by fitness (best first)
Sourcepub fn best_candidate(&self) -> Option<&Candidate<G>>
pub fn best_candidate(&self) -> Option<&Candidate<G>>
Get the best candidate
Sourcepub fn coverage_stats(&self) -> CoverageStats
pub fn coverage_stats(&self) -> CoverageStats
Calculate coverage statistics
Sourcepub fn record_request<GG: EvolutionaryGenome>(
&mut self,
request: &EvaluationRequest<GG>,
)
pub fn record_request<GG: EvolutionaryGenome>( &mut self, request: &EvaluationRequest<GG>, )
Record that an evaluation request was made
Sourcepub fn record_response(&mut self, was_skipped: bool)
pub fn record_response(&mut self, was_skipped: bool)
Record that a response was received
Sourcepub fn advance_generation(&mut self)
pub fn advance_generation(&mut self)
Advance to the next generation
Sourcepub fn update_fitness(&mut self, id: CandidateId, fitness: f64)
pub fn update_fitness(&mut self, id: CandidateId, fitness: f64)
Update fitness estimate for a candidate
Sourcepub fn update_fitness_with_uncertainty(
&mut self,
id: CandidateId,
estimate: FitnessEstimate,
)
pub fn update_fitness_with_uncertainty( &mut self, id: CandidateId, estimate: FitnessEstimate, )
Update fitness with full uncertainty information
Sourcepub fn sync_fitness_estimates(&mut self)
pub fn sync_fitness_estimates(&mut self)
Sync candidate fitness estimates from the aggregator
Updates all candidates with their current fitness estimates including uncertainty. Call this after processing responses to ensure candidates have up-to-date estimates.
Sourcepub fn all_fitness_estimates(&self) -> Vec<(CandidateId, FitnessEstimate)>
pub fn all_fitness_estimates(&self) -> Vec<(CandidateId, FitnessEstimate)>
Get fitness estimates with uncertainty for all candidates
Returns a vector of (CandidateId, FitnessEstimate) pairs.
Sourcepub fn candidates_by_uncertainty(&self) -> Vec<&Candidate<G>>
pub fn candidates_by_uncertainty(&self) -> Vec<&Candidate<G>>
Get candidates sorted by uncertainty (most uncertain first)
Useful for identifying which candidates need more evaluation.
Sourcepub fn average_uncertainty(&self) -> f64
pub fn average_uncertainty(&self) -> f64
Get the average uncertainty across all candidates
Sourcepub fn replace_population(&mut self, new_population: Vec<Candidate<G>>)
pub fn replace_population(&mut self, new_population: Vec<Candidate<G>>)
Replace the population with new candidates
Sourcepub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
Add metadata to the session
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get metadata value
Sourcepub fn response_rate(&self) -> f64
pub fn response_rate(&self) -> f64
Get response rate (responses / requests)
Source§impl<G> InteractiveSession<G>
File-based session persistence (requires checkpoint feature)
impl<G> InteractiveSession<G>
File-based session persistence (requires checkpoint feature)
Source§impl<G> InteractiveSession<G>
impl<G> InteractiveSession<G>
Sourcepub fn to_json(&self) -> Result<String, CheckpointError>
pub fn to_json(&self) -> Result<String, CheckpointError>
Serialize session to JSON string (WASM-compatible)
Sourcepub fn from_json(json: &str) -> Result<Self, CheckpointError>
pub fn from_json(json: &str) -> Result<Self, CheckpointError>
Deserialize session from JSON string (WASM-compatible)
Trait Implementations§
Source§impl<G> Clone for InteractiveSession<G>where
G: EvolutionaryGenome + Clone,
impl<G> Clone for InteractiveSession<G>where
G: EvolutionaryGenome + Clone,
Source§fn clone(&self) -> InteractiveSession<G>
fn clone(&self) -> InteractiveSession<G>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<G> Debug for InteractiveSession<G>where
G: EvolutionaryGenome + Debug,
impl<G> Debug for InteractiveSession<G>where
G: EvolutionaryGenome + Debug,
Source§impl<'de, G> Deserialize<'de> for InteractiveSession<G>
impl<'de, G> Deserialize<'de> for InteractiveSession<G>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<G> Serialize for InteractiveSession<G>
impl<G> Serialize for InteractiveSession<G>
Auto Trait Implementations§
impl<G> Freeze for InteractiveSession<G>
impl<G> RefUnwindSafe for InteractiveSession<G>where
G: RefUnwindSafe,
impl<G> Send for InteractiveSession<G>
impl<G> Sync for InteractiveSession<G>
impl<G> Unpin for InteractiveSession<G>where
G: Unpin,
impl<G> UnsafeUnpin for InteractiveSession<G>
impl<G> UnwindSafe for InteractiveSession<G>where
G: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.