The simplest way to model the Insulin vs Foods graph is with a pair of vectors.
Foods bring the BSL up at a particular rate. This rate is determined by the GI of the food, and the duration is determined by the quantity.
Insulin brings the BSL down at a particular rate. This is a much more deterministic rate.
An example pseudocode implementation may look like this.
BSL(t) = BSL(t-1) + ((GI / 100) * t) - (InsulinOnBoard * t) -
The simplest way to model the Insulin vs Foods graph is with a pair of vectors.
BSL(t) = BSL(t-1) + ((GI / 100) * t) - (InsulinOnBoard * t) -