Effective regulation of blood glucose in type 1 diabetes mellitus (T1DM) requires continuous insulin administration and remains a difficult control problem. This study compares a Deep Q-Network (DQN) insulin-dosing agent with a proportional–integral–derivative (PID) controller in silico. Glucose–insulin dynamics were described by a simplified Bergman minimal model with Gaussian meal disturbances.

Both controllers used the same five insulin infusion rates (0–4 U/h) and the same 5-min control interval. The DQN was trained on a standard three-meal day with three independent random seeds, and the PID gains were selected by grid search on the same day. Both controllers were then tested on the standard day, on high-carbohydrate and skipped-meal days not used for training, and with insulin sensitivity changed by ±30%.

Performance was assessed with time in range (TIR, 70–180 mg/dL), time below and above range, mean glucose, total insulin and cumulative reward. On the standard day, TIR was 100% with PID and 97.9 ± 3.6% with DQN (mean ± SD over seeds); in the high-carbohydrate scenario, it was 97.3% and 92.7 ± 6.0%, respectively.

Neither controller produced hypoglycemia in the meal scenarios. However, the DQN kept glucose close to the lower limit of the target range (minimum 72.8–76.0 mg/dL vs. 103.6–104.6 mg/dL with PID), delivered 1.8–3.2 times as much insulin and varied between training seeds; with a 30% increase in insulin sensitivity, one DQN agent spent 23 min below 70 mg/dL.

In this simplified setting, the DQN learned a usable dosing policy but did not outperform a tuned PID controller. Because the reward was constant inside the target range, the agent had no incentive to keep a margin from hypoglycemia, which shows that reward design directly affects controller safety.