Skip to main content

InteractiveSession

Struct InteractiveSession 

Source
pub struct InteractiveSession<G>{
    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: u32

Schema version for forward compatibility

§population: Vec<Candidate<G>>

Current population with fitness estimates

§generation: usize

Current generation number

§evaluations_requested: usize

Total evaluation requests made

§responses_received: usize

Total responses received (excluding skips)

§skipped: usize

Number of skipped evaluations

§aggregator: FitnessAggregator

Fitness aggregator state

§request_history: Vec<SerializedRequest>

History of evaluation requests (limited to recent history)

§metadata: HashMap<String, String>

Custom session metadata

§next_candidate_id: usize

Next candidate ID to assign

Implementations§

Source§

impl<G> InteractiveSession<G>

Source

pub fn new(aggregator: FitnessAggregator) -> Self

Create a new empty session

Source

pub fn with_population( population: Vec<Candidate<G>>, aggregator: FitnessAggregator, ) -> Self

Create a new session with initial population

Source

pub fn next_id(&mut self) -> CandidateId

Get the next candidate ID and increment counter

Source

pub fn add_candidate(&mut self, genome: G) -> CandidateId

Add a candidate to the population

Source

pub fn get_candidate(&self, id: CandidateId) -> Option<&Candidate<G>>

Get a candidate by ID

Source

pub fn get_candidate_mut( &mut self, id: CandidateId, ) -> Option<&mut Candidate<G>>

Get a mutable reference to a candidate by ID

Source

pub fn unevaluated_candidates(&self) -> Vec<&Candidate<G>>

Get all candidates that haven’t been evaluated

Source

pub fn ranked_candidates(&self) -> Vec<&Candidate<G>>

Get candidates sorted by fitness (best first)

Source

pub fn best_candidate(&self) -> Option<&Candidate<G>>

Get the best candidate

Source

pub fn coverage_stats(&self) -> CoverageStats

Calculate coverage statistics

Source

pub fn record_request<GG: EvolutionaryGenome>( &mut self, request: &EvaluationRequest<GG>, )

Record that an evaluation request was made

Source

pub fn record_response(&mut self, was_skipped: bool)

Record that a response was received

Source

pub fn advance_generation(&mut self)

Advance to the next generation

Source

pub fn update_fitness(&mut self, id: CandidateId, fitness: f64)

Update fitness estimate for a candidate

Source

pub fn update_fitness_with_uncertainty( &mut self, id: CandidateId, estimate: FitnessEstimate, )

Update fitness with full uncertainty information

Source

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.

Source

pub fn all_fitness_estimates(&self) -> Vec<(CandidateId, FitnessEstimate)>

Get fitness estimates with uncertainty for all candidates

Returns a vector of (CandidateId, FitnessEstimate) pairs.

Source

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.

Source

pub fn average_uncertainty(&self) -> f64

Get the average uncertainty across all candidates

Source

pub fn replace_population(&mut self, new_population: Vec<Candidate<G>>)

Replace the population with new candidates

Source

pub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)

Add metadata to the session

Source

pub fn get_metadata(&self, key: &str) -> Option<&String>

Get metadata value

Source

pub fn response_rate(&self) -> f64

Get response rate (responses / requests)

Source

pub fn skip_rate(&self) -> f64

Get skip rate (skips / requests)

Source§

impl<G> InteractiveSession<G>
where G: EvolutionaryGenome + Serialize + for<'de> Deserialize<'de>,

File-based session persistence (requires checkpoint feature)

Source

pub fn save(&self, path: &Path) -> Result<(), CheckpointError>

Save session to a file

Source

pub fn load(path: &Path) -> Result<Self, CheckpointError>

Load session from a file

Source§

impl<G> InteractiveSession<G>
where G: EvolutionaryGenome + Serialize + for<'de> Deserialize<'de>,

Source

pub fn to_json(&self) -> Result<String, CheckpointError>

Serialize session to JSON string (WASM-compatible)

Source

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>

Source§

fn clone(&self) -> InteractiveSession<G>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G> Debug for InteractiveSession<G>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, G> Deserialize<'de> for InteractiveSession<G>
where G: EvolutionaryGenome + Serialize + for<'a> Deserialize<'a>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<G> Serialize for InteractiveSession<G>
where G: EvolutionaryGenome + Serialize + for<'a> Deserialize<'a>,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,