from examples.example_1_simplest_case.ex_1_model_classes_with_vidigi_logging import Trial, g
from vidigi.animation import animate_activity_log
import pandas as pd
import plotly.io as pio
= "notebook" pio.renderers.default
Example 1: Simplest Case
= Trial()
my_trial
my_trial.run_trial()
4 nurses
50) my_trial.all_event_logs.head(
patient | pathway | event_type | event | time | resource_id | run | |
---|---|---|---|---|---|---|---|
0 | 1 | Simplest | arrival_departure | arrival | 0.000000 | NaN | 0 |
1 | 1 | Simplest | queue | treatment_wait_begins | 0.000000 | NaN | 0 |
2 | 1 | Simplest | resource_use | treatment_begins | 0.000000 | 1.0 | 0 |
3 | 2 | Simplest | arrival_departure | arrival | 3.399660 | NaN | 0 |
4 | 2 | Simplest | queue | treatment_wait_begins | 3.399660 | NaN | 0 |
5 | 2 | Simplest | resource_use | treatment_begins | 3.399660 | 2.0 | 0 |
6 | 3 | Simplest | arrival_departure | arrival | 8.497645 | NaN | 0 |
7 | 3 | Simplest | queue | treatment_wait_begins | 8.497645 | NaN | 0 |
8 | 3 | Simplest | resource_use | treatment_begins | 8.497645 | 3.0 | 0 |
9 | 4 | Simplest | arrival_departure | arrival | 8.596678 | NaN | 0 |
10 | 4 | Simplest | queue | treatment_wait_begins | 8.596678 | NaN | 0 |
11 | 4 | Simplest | resource_use | treatment_begins | 8.596678 | 4.0 | 0 |
12 | 5 | Simplest | arrival_departure | arrival | 8.608025 | NaN | 0 |
13 | 5 | Simplest | queue | treatment_wait_begins | 8.608025 | NaN | 0 |
14 | 6 | Simplest | arrival_departure | arrival | 11.359739 | NaN | 0 |
15 | 6 | Simplest | queue | treatment_wait_begins | 11.359739 | NaN | 0 |
16 | 7 | Simplest | arrival_departure | arrival | 19.509442 | NaN | 0 |
17 | 7 | Simplest | queue | treatment_wait_begins | 19.509442 | NaN | 0 |
18 | 8 | Simplest | arrival_departure | arrival | 22.877356 | NaN | 0 |
19 | 8 | Simplest | queue | treatment_wait_begins | 22.877356 | NaN | 0 |
20 | 9 | Simplest | arrival_departure | arrival | 26.653863 | NaN | 0 |
21 | 9 | Simplest | queue | treatment_wait_begins | 26.653863 | NaN | 0 |
22 | 1 | Simplest | resource_use_end | treatment_complete | 40.317385 | 1.0 | 0 |
23 | 1 | Simplest | arrival_departure | depart | 40.317385 | NaN | 0 |
24 | 5 | Simplest | resource_use | treatment_begins | 40.317385 | 1.0 | 0 |
25 | 10 | Simplest | arrival_departure | arrival | 40.737793 | NaN | 0 |
26 | 10 | Simplest | queue | treatment_wait_begins | 40.737793 | NaN | 0 |
27 | 2 | Simplest | resource_use_end | treatment_complete | 42.443230 | 2.0 | 0 |
28 | 2 | Simplest | arrival_departure | depart | 42.443230 | NaN | 0 |
29 | 6 | Simplest | resource_use | treatment_begins | 42.443230 | 2.0 | 0 |
30 | 4 | Simplest | resource_use_end | treatment_complete | 48.809628 | 4.0 | 0 |
31 | 4 | Simplest | arrival_departure | depart | 48.809628 | NaN | 0 |
32 | 7 | Simplest | resource_use | treatment_begins | 48.809628 | 4.0 | 0 |
33 | 3 | Simplest | resource_use_end | treatment_complete | 51.483457 | 3.0 | 0 |
34 | 3 | Simplest | arrival_departure | depart | 51.483457 | NaN | 0 |
35 | 8 | Simplest | resource_use | treatment_begins | 51.483457 | 3.0 | 0 |
36 | 11 | Simplest | arrival_departure | arrival | 71.026558 | NaN | 0 |
37 | 11 | Simplest | queue | treatment_wait_begins | 71.026558 | NaN | 0 |
38 | 5 | Simplest | resource_use_end | treatment_complete | 77.447488 | 1.0 | 0 |
39 | 5 | Simplest | arrival_departure | depart | 77.447488 | NaN | 0 |
40 | 9 | Simplest | resource_use | treatment_begins | 77.447488 | 1.0 | 0 |
41 | 6 | Simplest | resource_use_end | treatment_complete | 83.962251 | 2.0 | 0 |
42 | 6 | Simplest | arrival_departure | depart | 83.962251 | NaN | 0 |
43 | 10 | Simplest | resource_use | treatment_begins | 83.962251 | 2.0 | 0 |
44 | 12 | Simplest | arrival_departure | arrival | 87.458700 | NaN | 0 |
45 | 12 | Simplest | queue | treatment_wait_begins | 87.458700 | NaN | 0 |
46 | 13 | Simplest | arrival_departure | arrival | 87.465138 | NaN | 0 |
47 | 13 | Simplest | queue | treatment_wait_begins | 87.465138 | NaN | 0 |
48 | 7 | Simplest | resource_use_end | treatment_complete | 95.498040 | 4.0 | 0 |
49 | 7 | Simplest | arrival_departure | depart | 95.498040 | NaN | 0 |
= pd.DataFrame([
event_position_df 'event': 'arrival',
{'x': 50, 'y': 300,
'label': "Arrival" },
# Triage - minor and trauma
'event': 'treatment_wait_begins',
{'x': 205, 'y': 275,
'label': "Waiting for Treatment"},
'event': 'treatment_begins',
{'x': 205, 'y': 175,
'resource':'n_cubicles',
'label': "Being Treated"},
'event': 'exit',
{'x': 270, 'y': 70,
'label': "Exit"}
])
animate_activity_log(=my_trial.all_event_logs[my_trial.all_event_logs['run']==1],
event_log= event_position_df,
event_position_df=g(),
scenario=True,
debug_mode=False,
setup_mode=1,
every_x_time_units=True,
include_play_button=20,
icon_and_text_size=6,
gap_between_entities=25,
gap_between_rows=700,
plotly_height=200,
frame_duration=1200,
plotly_width=300,
override_x_max=500,
override_y_max=g.sim_duration,
limit_duration=25,
wrap_queues_at=125,
step_snapshot_max="dhm",
time_display_units=False,
display_stage_labels="https://raw.githubusercontent.com/Bergam0t/vidigi/refs/heads/main/examples/example_1_simplest_case/Simplest%20Model%20Background%20Image%20-%20Horizontal%20Layout.drawio.png",
add_background_image )
Animation function called at 18:03:52
Iteration through minute-by-minute logs complete 18:03:54
Snapshot df concatenation complete at 18:03:54
Reshaped animation dataframe finished construction at 18:03:54
Placement dataframe finished construction at 18:03:54
Output animation generation complete at 18:03:56
Total Time Elapsed: 4.92 seconds