Module sim_rust::functions[][src]

Expand description

This module will hold all the main functions that should be called. The specific order is recommended but some functions depend on the build up or tear down of others.

The following order order of operations is recommended:

Example

use sim_rust::Agent;
use sim_rust::functions::*;

//method 1 and 2 have the exact same outcome 

//method 1  
let mut env_1 = generate_default_env::<ExampleAgent>(10).unwrap();
env_1 = tick(env_1).unwrap(); //(or tick_collect)
collect(env_1);

//method 2
let mut env_2 = generate_default_tick_collect::<ExampleAgent>(10, 1, 1).unwrap();


 
// This is just a very simple implementation of an agent. 
struct ExampleAgent {
    age: u8,
}

impl Agent for ExampleAgent {
    fn generate() -> Result<Box<Self> ,&'static str> {
        let agent = Box::new(Self {age: 1});
        Ok(agent)
    }

    fn tick(&mut self) -> Result<(), &'static str> {
        self.age += 1;
        Ok(())
    }

    fn collect(&self)  -> Result<(), &'static str> {
        Ok(())
    }
}

Functions

Applies a collect to a passed in environment. This takes both the default environment provided by this library and custom defined environments created by the user.

Generates a standard environment with a specified agent. This environment is the standard implementation and does not provide any custom behavior.

Generates an environment and runs it the simulation in multiple processes. This also runs the generated simulation with the given parameters.

Generates a custom environment specified agent. This environment is the standard implementation and does not provide any custom behavior.

Generates a custom environment and runs it the simulation in multiple processes. This also runs the generated simulation with the given parameters.

Applies a tick to a passed in environment. This takes both the default environment provided by this library and custom defined environments created by the user.

Applies a tick and a collent to a passed in environment. This takes both the default environment provided by this library and custom defined environments created by the user. This function can be used when the user requies data from a certain time in a running simulation.