Skip to main content

Module plan

Module plan 

Source
Expand description

Core simulation harness APIs.

Re-exports all public types, traits, and functions from simvar_harness, including run_simulation, Sim, SimBootstrap, and SimConfig. Interaction planning utilities.

Provides the InteractionPlan trait for managing sequences of planned interactions.

Interaction planning utilities.

This module provides the InteractionPlan trait for managing sequences of planned interactions in simulations. Use this trait to define deterministic sequences of events or operations that should occur during a simulation run.

§Example

use simvar_harness::plan::InteractionPlan;

struct MyPlan {
    interactions: Vec<String>,
    index: usize,
}

impl InteractionPlan<String> for MyPlan {
    fn step(&mut self) -> Option<&String> {
        let result = self.interactions.get(self.index);
        if result.is_some() {
            self.index += 1;
        }
        result
    }

    fn gen_interactions(&mut self, count: u64) {
        for i in 0..count {
            self.interactions.push(format!("interaction-{i}"));
        }
    }

    fn add_interaction(&mut self, interaction: String) {
        self.interactions.push(interaction);
    }
}

Traits§

InteractionPlan
Trait for managing a sequence of planned interactions in a simulation.