import numpy as np
import pandas as pd
from examples.example_8_wide_resource_spacing.ex_8_model_classes import g, Trial
from vidigi.animation import animate_activity_log
import plotly.io as pio
= "notebook" pio.renderers.default
Creative Layouts - Single Hospital Ward Example
= Trial() clinic_simulation
clinic_simulation.trial_results
entity_id | event_type | event | time | pathway | run_number | timestamp | resource_id | |
---|---|---|---|---|---|---|---|---|
0 | 1 | arrival_departure | arrival | 0.000000 | None | 1 | None | NaN |
1 | 1 | queue | bed_wait_begins | 0.000000 | None | 1 | None | NaN |
2 | 1 | resource_use | stay_begins | 0.000000 | None | 1 | None | 1.0 |
3 | 2 | arrival_departure | arrival | 2.337500 | None | 1 | None | NaN |
4 | 2 | queue | bed_wait_begins | 2.337500 | None | 1 | None | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... |
2272 | 453 | resource_use_end | stay_complete | 8719.027185 | None | 100 | None | 2.0 |
2273 | 453 | arrival_departure | depart | 8719.027185 | None | 100 | None | NaN |
2274 | 457 | arrival_departure | arrival | 8719.147321 | None | 100 | None | NaN |
2275 | 457 | queue | bed_wait_begins | 8719.147321 | None | 100 | None | NaN |
2276 | 457 | resource_use | stay_begins | 8719.147321 | None | 100 | None | 1.0 |
242708 rows × 8 columns
= pd.DataFrame([
event_position_df 'event': 'arrival',
{'x': 50, 'y': 800,
'label': "Arrival" },
# Triage - minor and trauma
'event': 'bed_wait_begins',
{'x': 205, 'y': 700,
'label': "Waiting for Bed"},
'event': 'stay_begins',
{'x': 205, 'y': 175,
'resource':'number_of_beds',
'label': "In Ward"},
'event': 'depart',
{'x': 270, 'y': 70,
'label': "Exit"}
])
animate_activity_log(=clinic_simulation.trial_results[clinic_simulation.trial_results['run_number']==1],
event_log= event_position_df,
event_position_df=g(),
scenario# Key animation prep parameters
=6,
every_x_time_units="hours",
simulation_time_unit=g.sim_duration,
limit_duration=125,
step_snapshot_max# Animation display parameters
="dhm",
time_display_units=True,
include_play_button=True,
setup_mode=True,
debug_mode=200,
frame_duration# Text parameters
=True,
display_stage_labels=20,
text_size# Entity and queue size and spacing
=20,
entity_icon_size=25,
wrap_queues_at=6,
gap_between_entities=30,
gap_between_queue_rows# Resource size and spacing
=150,
gap_between_resources=100,
gap_between_resource_rows=40,
resource_icon_size=2,
wrap_resources_at='🛏️',
custom_resource_icon# Plot size
=600,
plotly_height=1000,
plotly_width# Internal plot coordinates
=300,
override_x_max=900,
override_y_max )
Animation function called at 12:02:44
Iteration through time-unit-by-time-unit logs complete 12:02:51
Snapshot df concatenation complete at 12:02:51
Reshaped animation dataframe finished construction at 12:02:51
Placement dataframe finished construction at 12:02:51
Output animation generation complete at 12:02:57
Total Time Elapsed: 12.89 seconds