[][src]Struct sim::simulator::Simulation

pub struct Simulation { /* fields omitted */ }

The Simulation struct is the core of sim, and includes everything needed to run a simulation - models, connectors, and a random number generator. State information, specifically global time and active messages are additionally retained in the struct.

Implementations

impl Simulation[src]

pub fn post_json(models: &str, connectors: &str) -> Simulation[src]

Like post_yaml, this constructor method creates a simulation from a supplied configuration (models and connectors).

pub fn put_json(&mut self, models: &str, connectors: &str)[src]

Like put_yaml, this method sets the models and connectors of an existing simulation.

pub fn get_json(&self) -> String[src]

This method provides the simulation state in a "pretty" serialized JSON format - with line breaks and indentations. The simulation details not included in this serialization are internal implementation details. If it is not included in the serialization, the data is not required to specify the simulation state, and it has been excluded deliberately.

pub fn post_yaml(models: &str, connectors: &str) -> Simulation[src]

Like post_json, this constructor method creates a simulation from a supplied configuration (models and connectors).

pub fn put_yaml(&mut self, models: &str, connectors: &str)[src]

Like put_json, this method sets the models and connectors of an existing simulation.

pub fn get_yaml(&self) -> String[src]

This method provides the simulation state in a yaml serialized JSON format - with line breaks and indentations. The simulation details not included in this serialization are internal implementation details. If it is not included in the serialization, the data is not required to specify the simulation state, and it has been excluded deliberately.

pub fn get_messages_js(&self) -> Array[src]

Simulation steps generate messages, which are then consumed on subsequent simulation steps. These messages between models in a simulation drive much of the discovery, analysis, and design. This accessor method provides the list of active messages, at the current point of time in the simulation. Message history is not retained, so simulation products and projects should collect messages as needed throughout the simulation execution.

pub fn get_messages_json(&self) -> String[src]

This method is like get_messages_js, but returns the messages as JSON.

pub fn get_messages_yaml(&self) -> String[src]

This method is like get_messages_js, but returns the messages as YAML.

pub fn get_global_time(&self) -> f64[src]

An accessor method for the simulation global time.

pub fn status(&self, model_id: &str) -> String[src]

This method provides a mechanism for getting the status of any model in a simulation. The method takes the model ID as an argument, and returns the current status string for that model.

pub fn reset(&mut self)[src]

To enable simulation replications, the reset method resets the state of the simulation, except for the random number generator. Recreating a simulation from scratch for additional replications does not work, due to the random number generator seeding.

pub fn reset_messages(&mut self)[src]

Clear the active messages in a simulation.

pub fn reset_global_time(&mut self)[src]

Reset the simulation global time to 0.0.

pub fn inject_input(&mut self, message: Message)[src]

Input injection creates a message during simulation execution, without needing to create that message through the standard simulation constructs. This enables live simulation interaction, disruption, and manipulation - all through the standard simulation message system.

pub fn inject_input_json(&mut self, message: &str)[src]

This method is like inject_input, but the message is provided in JSON format.

pub fn inject_input_yaml(&mut self, message: &str)[src]

This method is like inject_input, but the message is provided in YAML format.

pub fn step(&mut self)[src]

The simulation step is foundational for a discrete event simulation. This method executes a single discrete event simulation step, including internal state transitions, external state transitions, message orchestration, and global time accounting.

pub fn step_until_js(&mut self, until: f64) -> Array[src]

This method executes simulation step calls, until a global time has been exceeded. At which point, the messages from all the simulation steps are returned.

pub fn step_until_json(&mut self, until: f64) -> String[src]

This method is like step_until_js, but returns the messages as JSON.

pub fn step_until_yaml(&mut self, until: f64) -> String[src]

This method is like step_until_js, but returns the messages as YAML.

pub fn step_n_js(&mut self, n: usize) -> Array[src]

This method executes the specified number of simulation steps, n. Upon execution of the n steps, the messages from all the steps are returned.

pub fn step_n_json(&mut self, n: usize) -> String[src]

This method is like step_n_js, but returns the messages as JSON.

pub fn step_n_yaml(&mut self, n: usize) -> String[src]

This method is like step_n_js, but returns the messages as YAML.

Trait Implementations

impl Clone for Simulation[src]

impl Default for Simulation[src]

impl<'de> Deserialize<'de> for Simulation[src]

impl FromWasmAbi for Simulation[src]

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

impl IntoWasmAbi for Simulation[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

impl OptionFromWasmAbi for Simulation[src]

impl OptionIntoWasmAbi for Simulation[src]

impl RefFromWasmAbi for Simulation[src]

type Abi = u32

The wasm ABI type references to Self are recovered from.

type Anchor = Ref<'static, Simulation>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more

impl RefMutFromWasmAbi for Simulation[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

type Anchor = RefMut<'static, Simulation>

Same as RefFromWasmAbi::Anchor

impl Serialize for Simulation[src]

impl WasmDescribe for Simulation[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ReturnWasmAbi for T where
    T: IntoWasmAbi
[src]

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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