1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Simulation execution functionality
use AgentSet;
use Env;
use tqdm;
use SeedableRng;
use Xoroshiro128StarStar;
/// Run a simulation for a fixed number of steps
///
/// Each step updates the state of the agents (who
/// in turn can submit instructions to the environment
/// and then update the environment state)
///
/// # Examples
///
/// ```
/// use bourse_de::{Env, sim_runner};
/// use bourse_de::agents::AgentSet;
/// use rand::RngCore;
///
/// // Dummy agent-type
/// struct Agents{}
///
/// impl AgentSet for Agents {
/// fn update<R: RngCore>(
/// &mut self, env: &mut Env, _rng: &mut R
/// ) {}
/// }
///
/// let mut env = bourse_de::Env::new(0, 1, 1_000, true);
/// let mut agents = Agents{};
///
/// // Run for 100 steps from seed 101
/// sim_runner(&mut env, &mut agents, 101, 100, true)
/// ```
///
/// # Arguments
///
/// - `env` - Simulation environment
/// - `agents` - Agent(s) implementing the [AgentSet] trait
/// - `seed` - Random seed
/// - `n_steps` - Number of simulation steps
/// - `show_progress` - Show progress bar
///