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
pio.renderers.default = "notebook"Creative Layouts - Single Hospital Ward Example
clinic_simulation = Trial()clinic_simulation.trial_results| entity_id | event_type | event | time | run_number | resource_id | |
|---|---|---|---|---|---|---|
| 0 | 1 | arrival_departure | arrival | 0.000000 | 1 | NaN |
| 1 | 1 | queue | bed_wait_begins | 0.000000 | 1 | NaN |
| 2 | 1 | resource_use | stay_begins | 0.000000 | 1 | 1.0 |
| 3 | 2 | arrival_departure | arrival | 2.337500 | 1 | NaN |
| 4 | 2 | queue | bed_wait_begins | 2.337500 | 1 | NaN |
| ... | ... | ... | ... | ... | ... | ... |
| 2272 | 453 | resource_use_end | stay_complete | 8719.027185 | 100 | 2.0 |
| 2273 | 453 | arrival_departure | depart | 8719.027185 | 100 | NaN |
| 2274 | 457 | arrival_departure | arrival | 8719.147321 | 100 | NaN |
| 2275 | 457 | queue | bed_wait_begins | 8719.147321 | 100 | NaN |
| 2276 | 457 | resource_use | stay_begins | 8719.147321 | 100 | 1.0 |
242708 rows × 6 columns
event_position_df = pd.DataFrame([
{'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(
event_log=clinic_simulation.trial_results[clinic_simulation.trial_results['run_number']==1],
event_position_df= event_position_df,
scenario=g(),
# Key animation prep parameters
every_x_time_units=6,
simulation_time_unit="hours",
limit_duration=g.sim_duration,
step_snapshot_max=125,
# Animation display parameters
time_display_units="dhm",
include_play_button=True,
setup_mode=True,
debug_mode=True,
frame_duration=200,
# Text parameters
display_stage_labels=True,
text_size=20,
# Entity and queue size and spacing
entity_icon_size=20,
wrap_queues_at=25,
gap_between_entities=6,
gap_between_queue_rows=30,
# Resource size and spacing
gap_between_resources=150,
gap_between_resource_rows=100,
resource_icon_size=40,
wrap_resources_at=2,
custom_resource_icon='🛏️',
# Plot size
plotly_height=600,
plotly_width=1000,
# Internal plot coordinates
override_x_max=300,
override_y_max=900,
)Animation function called at 13:18:12
Iteration through time-unit-by-time-unit logs complete 13:18:18
Snapshot df concatenation complete at 13:18:18
Reshaped animation dataframe finished construction at 13:18:18
Placement dataframe finished construction at 13:18:18
Output animation generation complete at 13:18:24
Total Time Elapsed: 11.89 seconds