Autonomous Hospital Operations with DeepMind AlphaEvolve, Cloud Spanner Graph, and Gemini Enterprise
Optimizing Emergency Department Patient Flow and Clinician Workload via LLM Evolutionary Code Synthesis
Authors (listed alphabetically): Aaron Sengstacken, Sarita A. Joshi
Emergency department (ED) crowding is among the most critical and intractable systemic challenges facing modern healthcare systems. When inpatient floors operate in departmental silos, acute emergency patients back up in ED hallways for 12 to 24 hours. Prolonged emergency department boarding directly correlates with up to a 30% increase in inpatient mortality and adverse events (Bernstein et al., 2009), alongside severe clinician burnout (Aiken et al., 2002).
Traditional hospital operations rely on static heuristics, rigid departmental bed quotas, and manual bed-placement spreadsheets. While recent operations research — such as the empirical study by Wang et al. (2025) published in INQUIRY — demonstrated that cross-departmental bed sharing significantly reduces boarding, static heuristic rules introduce significant clinical trade-offs:
- Uncontrolled Bed Flooding: Open borrowing policies flood scarce surgical specialty suites (such as Cardiac and Thoracic Surgery) with lower-acuity general medicine patients, starving surgical emergencies.
- Clinician Burnout & Workload Imbalance: Unregulated patient spills push nurse workload ratios well past safe clinical thresholds (> 60% utilization or > 1:4 staffing ratios), driving adverse events and staff turnover.
- Infection Control Breaches: Ad-hoc bed placement risks placing infectious respiratory cases adjacent to immunocompromised post-operative or oncology patients.
In this medium article, we present an end-to-end autonomous hospital operations platform built on Google Cloud. By combining DeepMind AlphaEvolve in Gemini Enterprise with Gemini 3.6 Flash and Cloud Spanner Graph, our system autonomously synthesizes, evaluates, and deploys human-inspectable Python dispatch algorithms benchmarked against clinical encounters from PhysioNet MIMIC-IV-ED (v2.2).

The Clinical Challenge: Why Static Heuristics Fail
In emergency care, bed allocation is a complex combinatorial optimization problem governed by five interconnected clinical constraints:
- Triage Severity (TTAS / ESI Levels 1–5): Resuscitation cases (Level 1) require immediate zero-delay placement, while Level 3–5 cases can utilize short-stay observation units.
- Diurnal Inflow Spikes: Emergency arrivals surge between 11:00 AM and 7:00 PM, causing acute bottlenecks if bed turnaround is slow.
- Surgical Bed Starvation: High-acuity surgical suites have limited physical capacity (e.g., 1 to 4 beds). Uncontrolled borrowing locks out trauma surgeries.
- Nurse-to-Patient Staffing Limits: Nurse utilization must remain strictly between 45% and 60% (≤ 1:4.2 staffing ratio). Workloads above 60% trigger exponential burnout and adverse events.
- Infection Control Segregation: Immunocompromised oncology and surgical units must remain isolated from general respiratory infection spillover.
What is DeepMind AlphaEvolve?
AlphaEvolve is a specialized AI coding agent designed for algorithmic discovery and mathematical search over NP-hard combinatorial optimization problems.
Unlike standard LLM code generation tools that focus on writing boilerplate code from natural language prompts, AlphaEvolve operates on functional code blocks and uses an evolutionary search loop to iteratively mutate, test, and score executable algorithms against quantitative performance evaluators.
The 5 Core Components of the AlphaEvolve Optimization Paradigm
- Candidate Program Search Space: Executable Python Bed Placement Heuristics.
- LLM Mutation Engine: Gemini 3.6 Flash with Thinking Mode mutating program code.
- Evaluator & Simulator: Closed-loop discrete-event simulation on MIMIC-IV-ED encounters.
- Multi-Objective Pareto Fitness: Co-optimizing throughput, workload, and capacity headroom.
- Reward Hacking Prevention: 5 Clinical Safety Audit Gates enforcing hard clinical invariants.
When developing with AlphaEvolve in Gemini Enterprise, agentic coding assistants (such as Antigravity) guide engineers through the complete end-to-end algorithmic discovery lifecycle across six specialized AlphaEvolve Skills:
- AlphaEvolve Consultant (alpha_evolve_consultant): Frames the complex clinical optimization problem, balancing throughput against clinician workload constraints.
- AlphaEvolve Experiment Design (alpha_evolve_experiment_design): Defines the functional Python code block (calculate_bed_placement_priority) and codifies 5 pre-deployment clinical safety audit gates.
- AlphaEvolve Orchestrator (alpha_evolve_orchestrator): Configures the closed-loop discrete-event simulation harness driven by empirical encounters from PhysioNet MIMIC-IV-ED (v2.2).
- AlphaEvolve Runner (alpha_evolve_runner): Drives the evolutionary search loop using gemini-3.6-flash with Thinking Mode across parallel island populations.
- AlphaEvolve Monitor (alpha_evolve_monitor): Streams real-time progress, tracking non-dominated Pareto frontiers and mutational lineage trees.
- AlphaEvolve Post-Experiment (alpha_evolve_post_experiment): Extracts certified Generation 25 winning heuristics and deploys production microservices to Google Cloud Run.
(See the official Google Cloud AlphaEvolve Repository for full skill definitions).
Spectrum of Optimization Solvers & Heuristics across Operations Research Paradigms
To understand where AlphaEvolve delivers transformative value relative to classical algorithms, the following comparative breakdown maps out AlphaEvolve’s positioning across optimization paradigms (summarized from the Official Google Cloud Gemini Enterprise Documentation):

System Architecture Overview
Our production system deploys an enterprise-grade reference topology on Google Cloud:

Component Specifications
- AlphaEvolve in Gemini Enterprise: Drives the evolutionary search loop with gemini-3.6-flash in the global region, utilizing structured Thinking Config to discover non-linear code mutations.
- Cloud Spanner Graph: Manages the live semantic property graph of hospital units, physical beds, patient encounters, and dynamic borrowing channels with 99.999% availability and native Graph Query Language (GQL).
- Google Cloud Run: Hosts the sub-10ms FastAPI REST dispatch backend and the interactive Streamlit Command Cockpit with zero-to-N autoscaling.
- Artifact Registry & Cloud Build: Provides immutable, secure container pipelines with automated vulnerability scanning.
Empirical Clinical Grounding: Ingesting MIMIC-IV-ED Encounters
Rather than relying on synthetic arrival distributions alone, our pipeline parses encounter records from the PhysioNet MIMIC-IV-ED (v2.2) database:
# data_loader.py: PhysioNet MIMIC-IV-ED Encounter Loader
from dataclasses import dataclass
from typing import List
import pandas as pd
@dataclass
class MIMICPatientEncounter:
"""Clinical encounter record from MIMIC-IV-ED dataset."""
subject_id: int
stay_id: int
arrival_time_hours: float
triage_level: int # TTAS/ESI Level 1 (Resuscitation) to 5 (Non-urgent)
chief_complaint: str
target_department: str
requires_inpatient: bool
requires_observation: bool
actual_ed_los_hours: float
class MIMICDataLoader:
"""Loads and parses PhysioNet MIMIC-IV-ED emergency admissions."""
def load_patients(
self, csv_path: str = "mimic_ed_demo.csv"
) -> List[MIMICPatientEncounter]:
"""Parses real-world clinical encounters with ground-truth LOS."""
df = pd.read_csv(csv_path)
patients = []
for _, row in df.iterrows():
patients.append(
MIMICPatientEncounter(
subject_id=int(row["subject_id"]),
stay_id=int(row["stay_id"]),
arrival_time_hours=float(row["arrival_hour"]),
triage_level=int(row["triage_acuity"]),
chief_complaint=str(row["chiefcomplaint"]),
target_department=str(row["target_dept"]),
requires_inpatient=bool(row["admit_inpatient"]),
requires_observation=bool(row["admit_obs"]),
actual_ed_los_hours=float(row["actual_los_hours"]),
)
)
return patients
Modeling Hospital Topology with Cloud Spanner Graph
We model the 9 hospital departments (309 total inpatient beds) as an operational graph in Cloud Spanner using Property Graph DDL:
-- Cloud Spanner Graph DDL Schema
CREATE TABLE Departments (
department_id STRING(64) NOT NULL,
division STRING(64) NOT NULL,
-- Divisions: Internal Med, Surgery, Obs
total_beds INT64 NOT NULL,
active_occupancy INT64 NOT NULL,
borrowed_beds INT64 NOT NULL,
max_borrow_pct FLOAT64 NOT NULL
) PRIMARY KEY (department_id);
CREATE TABLE ActivePatients (
patient_id STRING(64) NOT NULL,
arrival_time TIMESTAMP NOT NULL,
triage_level INT64 NOT NULL,
chief_complaint STRING(MAX),
target_department STRING(64) NOT NULL,
assigned_bed_dept STRING(64),
placement_status STRING(32) NOT NULL
-- Status: WAITING, PLACED, OBSERVATION
) PRIMARY KEY (patient_id);
-- Define Semantic Property Graph
CREATE PROPERTY GRAPH HospitalOperationsGraph
VERTEX TABLES (
Departments LABEL Department,
ActivePatients LABEL Patient
)
EDGE TABLES (
ActivePatients AS RoutedTo
SOURCE KEY (patient_id)
REFERENCES ActivePatients (patient_id)
DESTINATION KEY (assigned_bed_dept)
REFERENCES Departments (department_id)
LABEL ROUTED_TO
);
We query active patient flow, cross-department borrowing, and surgical headroom using native GQL:
# Query Spanner Graph using native GQL
gql_query = """
MATCH (p:Patient)-[:ROUTED_TO]->(d:Department)
WHERE d.division = 'Surgery' AND p.triage_level <= 2
RETURN p.patient_id, p.triage_level, d.department_id, d.active_occupancy
"""
The Evolutionary Code Discovery Loop
The AlphaEvolve evolutionary loop operates through continuous mutation, code syntax verification, and multi-objective simulation:
# alpha_evolve_gemini_engine.py
from google import genai
from google.genai import types
def evolve_heuristic(
client: genai.Client, parent_code: str, feedback: str
) -> str:
"""Synthesizes evolved bed allocation code."""
prompt = f"""
You are DeepMind AlphaEvolve for Hospitals.
Optimize this Python bed allocation policy.
PARENT CODE:
{parent_code}
OPERATIONAL FEEDBACK:
{feedback}
OPTIMIZATION OBJECTIVES:
1. Minimize ED LOS > 6h (< 0.1% target).
2. Nurse load: 45% - 60% (≤ 1:4.2 ratio).
3. Surgical headroom: ≥ 2 beds reserved.
4. Diurnal peak lookahead: 11:00 - 19:00.
Output only executable function
calculate_bed_placement_priority.
"""
response = client.models.generate_content(
model="gemini-3.6-flash",
contents=[prompt],
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(
thinking_level="MEDIUM"
),
temperature=0.7,
),
)
return response.text
The Evolved Breakthrough: Generation 25 Algorithm
Across 25 evolutionary generations, AlphaEvolve synthesized a dispatch policy that outperformed traditional operations research heuristics: Acuity-Preserved Diurnal Headroom Hedging with Cross-Division Elastic Bridging:
# Evolved Policy: AlphaEvolve Generation 25
def calculate_bed_placement_priority(
patient, available_beds, unit_loads, current_hour=14.0
):
"""
AlphaEvolve Evolved Heuristic:
Diurnal Headroom & Elastic Bridging Policy.
"""
target = patient.target_department
triage = getattr(patient, "triage_level", 3)
is_diurnal_peak = 11.0 <= (current_hour % 24) <= 19.0
# 1. Primary Placement Baseline
if available_beds.get(target, 0) > 0:
return target, None
# 2. Resuscitation (TTAS 1 & 2): Elastic Bridge
# Selects lowest-workload unit across divisions
if triage in [1, 2]:
eligible_units = [
(dept, avail)
for dept, avail in available_beds.items()
if avail >= 1 and "Observation" not in dept
]
if eligible_units:
# Rank by lowest nurse workload
best_dept = min(
eligible_units,
key=lambda x: unit_loads.get(x[0], 0.5),
)[0]
return target, best_dept
# 3. Urgent (TTAS 3): Intra-Division Borrowing
# Protects surgical headroom (≥ 2 beds during peak)
required_headroom = 2 if is_diurnal_peak else 1
division_siblings = [
(dept, avail)
for dept, avail in available_beds.items()
if avail > required_headroom and "Surgery" not in dept
]
if division_siblings:
best_sibling = max(
division_siblings, key=lambda x: x[1]
)[0]
return target, best_sibling
# 4. Stable (TTAS 4 & 5): Observation Holding Buffer
if available_beds.get("General Observation", 0) > 2:
return target, "General Observation"
return None, None
Visualizing Evolutionary Discovery: Split-Screen Replay & Pareto Frontier
During the evolutionary run, AlphaEvolve maintains a synchronized split-screen replay pairing the evolving Python code diff with the multi-dimensional Pareto frontier:


Mechanics of the Pareto Frontier & Dynamic — ⭐ Better Marker
- Multi-Objective Trade-Off: The horizontal axis tracks Metric 1: ED Patients < 6h LOS (%), while the vertical axis tracks Metric 2: Nurse Workload Utilization (%).
- Exploration vs. Exploitation: Purple points represent exploratory mutations evaluated across island populations.
- The Leading Edge: The glowing blue trajectory marks the non-dominated Pareto frontier. As AlphaEvolve discovers net-new logic (such as diurnal headroom hedging), the glowing golden — ⭐ Better marker advances dynamically towards the optimal operating regime (< 0.1% boarding breaches, 52.4% balanced nurse load), as shown in the live recording above.
Phylogenetic Evolutionary Tree: Code Discovery Lineage
To inspect how individual code modifications branch and evolve over time, AlphaEvolve records a full phylogenetic lineage tree:

Decoupling Winners from Pruned Mutational Dead Ends
- Root ‘Seed’ (Baseline S0): The initial rigid departmental silo policy.
- Generation 1 Exploration (G1.C1 to G1.C12): Twelve parallel candidate code mutations explore different borrowing heuristics. Candidates G1.C3, G1.C8, and G1.C11 succeed (emerald green), while unconstrained borrowing variants like G1.C5 trigger nurse overload and are pruned (ruby red).
- Generation 2 & 3 Convergence: Branching from G1.C3 leads to G2.C10 and culminates in G3.C8 ⭐ (Active Champion), achieving a 98.71 Fitness Score (< 0.1% LOS > 6h, 52.4% Nurse Load) with full clinical safety gate compliance.
Multi-Objective Pareto Validation: The 5 Safety Gates
To prevent reward hacking — where an algorithm artificially maximizes throughput by unsafely packing high-acuity patients into understaffed wards — AlphaEvolve subjects every candidate to 5 Pre-Deployment Clinical Safety Gates:
- [GATE 1] Infection Control Segregation: AUDIT PASS — Zero respiratory/oncology cross-contamination.
- [GATE 2] Nurse Staffing Ratio Compliance: 1:4.2 PASS — Workload bounded at 52.4% (< 60%).
- [GATE 3] Surgical Emergency Headroom: AUDIT PASS — ≥ 2 beds reserved in Thoracic & Cardiac.
- [GATE 4] High-Acuity Placement Latency: < 15min PASS — TTAS 1–2 immediate placement.
- [GATE 5] Boarding Mitigation (> 6h LOS): < 0.1% PASS — Boarding breaches reduced to < 0.1%.

Scientific Methodology & Experimental Alignment
To maintain scientific rigor and minimize confounding variables, our benchmarking methodology bridges the theoretical operations research framework of Wang et al. (2025) with empirical validation from PhysioNet MIMIC-IV-ED (v2.2):
- Standardized Clinical Topology: The physical hospital infrastructure (309 beds across 9 specialty departments in Internal Medicine, Surgery, and Observation), clinical pathway stages, and nurse-to-patient staffing parameters are modeled directly after the published discrete-event simulation (DES) topology defined by Wang et al. (2025).
- Empirical Encounter Cohorts: Rather than relying solely on synthetic arrival distributions, the simulation engine is driven by actual emergency department patient traces from PhysioNet MIMIC-IV-ED, incorporating triage acuities (ESI/TTAS 1–5), clinical chief complaints, and admission disposition requirements.
- Controlled Apples-to-Apples Evaluation: All benchmark policies — including Wang et al. S0 (Departmental Silos), Wang et al. S2 (Unconstrained Cross-Department Sharing), and Wang et al. Strategy 4 (Static Mixed-Integer Programming with 5% Fixed Borrowing) — were faithfully re-implemented and evaluated within the exact same simulation testbed alongside AlphaEvolve’s evolved heuristics across identical replication seeds.
- Dynamic Lookahead vs. Static MIP Borrowing: While Wang et al. Strategy 4 applies a static 5% fixed borrowing cap, AlphaEvolve synthesizes time-aware diurnal peak lookahead (11:00–19:00) and elastic cross-division bridging. This dynamically unlocks 20–30% borrowing headroom strictly when surgical safety headroom (≥ 2 beds) and nurse utilization (45–60%) safely permit it.
This experimental design ensures that all reported metrics reflect pure algorithmic optimization performance under identical clinical arrival pressures.
Comparative Evaluation of Re-Implemented Policies

* Note: Baselines S0, S2, and Strategy 4 represent faithful re-implementations of the heuristic and MIP policies proposed by Wang et al. (2025), evaluated under identical MIMIC-IV-ED empirical arrival streams (N=222 cohort) and clinical constraints within the exact same simulation harness. Under extreme multi-day catastrophe scenarios exceeding total physical facility bed capacity, queuing will naturally form.
Inside the Clinical Operations Command Cockpit
The operations platform provides a multi-view Command Cockpit structured across five operational tabs:
- Hospital State Graph Cockpit: Real-time GQL graph queries, live bed occupancy counters across 309 hospital beds, and an interactive 7-stage clinical workflow stepper (ED Triage Inflow, Specialty Capacity, Surge Prediction, Dynamic Borrowing, Pareto Optimization, Bed Dispatch, Safety Validation).
- AlphaEvolve Split-Screen Replay & Phylogenetic Workbench: Synchronized playback of code mutations alongside the 2D Pareto frontier and phylogenetic tree visualizer.
- Department Floor View: Live capacity heatmaps across Pulmonology, Gastroenterology, Neurology, Nephrology, General Surgery, Thoracic Surgery, Cardiac Surgery, and Observation.
- Live Patient Triage & Dispatch: Interactive clinical admission interface evaluating sub-10ms routing decisions.
- Clinical Dataset Explorer (MIMIC-IV-ED): Ingestion explorer for 222 emergency encounters with ground-truth triage acuities and lengths of stay.
Deploying to Production on Google Cloud Run
Both backend and frontend services are packaged as microservices deployed directly to Google Cloud Run:
# 1. Enable Google Cloud APIs
gcloud services enable \
discoveryengine.googleapis.com \
spanner.googleapis.com \
run.googleapis.com \
artifactregistry.googleapis.com \
cloudbuild.googleapis.com
# 2. Build and Deploy FastAPI REST Backend to Cloud Run
gcloud builds submit --tag us-central1-docker.pkg.dev/$PROJECT_ID/hcls-alphaevolve/fastapi-backend:latest .
gcloud run deploy ae-hcls-fastapi-backend \
--image=us-central1-docker.pkg.dev/$PROJECT_ID/hcls-alphaevolve/fastapi-backend:latest \
--platform=managed \
--region=us-central1 \
--allow-unauthenticated \
--port=8000 \
--min-instances=1 \
--max-instances=10 \
--cpu=2 \
--memory=4Gi \
--set-env-vars=PROJECT_ID=$PROJECT_ID,LOCATION=global,GEMINI_MODEL=gemini-3.6-flash
# 3. Build and Deploy Streamlit Command Cockpit to Cloud Run
gcloud builds submit -f Dockerfile.dashboard --tag us-central1-docker.pkg.dev/$PROJECT_ID/hcls-alphaevolve/command-cockpit:latest .
gcloud run deploy ae-hcls-command-cockpit \
--image=us-central1-docker.pkg.dev/$PROJECT_ID/hcls-alphaevolve/command-cockpit:latest \
--platform=managed \
--region=us-central1 \
--allow-unauthenticated \
--port=8501 \
--min-instances=1 \
--max-instances=5 \
--cpu=2 \
--memory=4Gi \
--set-env-vars=PROJECT_ID=$PROJECT_ID,LOCATION=global,GEMINI_MODEL=gemini-3.6-flash
Key Takeaways for Clinical AI & Healthcare Technology Leaders
- Code Transparency Over Black-Box Models: In high-stakes healthcare operations, uninterpretable neural network dispatchers cannot pass clinical governance boards. AlphaEvolve generates clean, human-readable Python code that hospital chief medical officers and operations engineers can inspect, audit, and modify.
- Multi-Objective Pareto Safety: Optimizing solely for throughput may have clinical side effects. By codifying clinician workload boundaries (1:4.2 nurse staffing ratio) and surgical reservation gates directly into the fitness function, AlphaEvolve protects clinician well-being alongside patient flow.
- Low-Latency Graph Topology with Cloud Spanner: Modeling hospital beds, wards, and patient routing channels as a property graph enables sub-millisecond path traversals, unlocking real-time operational agility across distributed hospital systems.
References
- Wang et al. (2025): Optimizing Emergency Department Patient Flow Through Bed Allocation Strategies: A Discrete-Event Simulation Study.
- Johnson et al. (2023): MIMIC-IV-ED: Emergency Department Module (v2.2).
- Bernstein et al. (2009): The Effect of Emergency Department Crowding on Clinically Oriented Outcomes.
- Aiken et al. (2002): Hospital nurse staffing and patient mortality, nurse burnout, and job dissatisfaction.
- Novikov et al. (2025): AlphaEvolve: A coding agent for scientific and algorithmic discovery.
- Google Cloud Spanner Graph Documentation: Graph Query Language (GQL) and Property Graph Modeling. Google Cloud Platform.
- Google Cloud Gemini Enterprise Documentation: AlphaEvolve Developer Guide: Algorithmic Discovery and Evolutionary Synthesis. Google Cloud Documentation.
Autonomous Hospital Operations with DeepMind AlphaEvolve, Cloud Spanner Graph, and Gemini… was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/autonomous-hospital-operations-with-deepmind-alphaevolve-cloud-spanner-graph-and-gemini-8f3d4aab54d3?source=rss—-e52cf94d98af—4
