Vet Clinic Simulator

ODE-based resource scheduling for a small animal hospital

Time

Petri Net Schema

How It Works: Petri Net ODE Scheduling

This simulator models a veterinary hospital as a Petri net with 32 places and 32 transitions. Instead of discrete event simulation, it uses continuous ODE solving (mass-action kinetics) to predict patient flow, staff utilization, and financial outcomes across a full clinic day.

The model has three categories of places:

A patient flows through the net: arrivalwait_*in_*checkoutdischarged. Surgery patients detour through in_recovery first.

Why This Matters

Resource places create bottlenecks naturally. When all DVMs are busy (0 tokens in dvm_avail), exam transitions cannot fire and the queue grows — exactly what happens in a real clinic.

Each clinical service has a start/finish transition pair:

Triage transitions (triage_to_exam, triage_to_tech, etc.) route arriving patients to the correct queue based on the service mix sliders.

The Source Transition

patient_arrives is a source transition with no input places. Its rate directly controls how many patients enter the system per hour. After 5:30 PM, this rate drops to zero — no new arrivals, but in-progress procedures finish.

Instead of stepping through individual events, the simulator solves a system of ordinary differential equations:

d[place]/dt = Σ(producing transitions) - Σ(consuming transitions) flux(transition) = rate × Π([input_place]^weight)
Why Piecewise?

Staff levels change throughout the day (lunch breaks, part-time shifts ending). The simulator splits the day into segments at each staff change, solving each segment independently and stitching the results together. This captures the 12:30 PM lunch dip and afternoon staffing changes accurately.

What the ODE Reveals

The financial dashboard is derived directly from the ODE solution:

The gross profit margin emerges from the interplay of service mix, staffing levels, and patient volume — all encoded in the Petri net topology.

The Schedule view introduces a human dimension to the Petri net model:

This is where Petri nets shine: the same model works for both the simple slider-based staffing and the detailed per-employee schedule. The ODE solver doesn't care where the numbers come from.