Presented here are techniques for controlling glucose levels of a patient based on predicted time to a target glucose level. One methodology predicts a trajectory of the blood glucose level based on past observations of the blood glucose level, determines a cost expression based on the trajectory, and affects a future command to an infusion pump to affect a cost value according to the cost expression. Another methodology defines a target blood glucose concentration level for the patient, observes a current blood glucose concentration for the patient based on signals received from a blood-glucose sensor, and predicts a duration of time for the patient's blood glucose concentration to reach the target blood glucose concentration level based on the observed current blood glucose concentration.