## 4 Tesseratus Model  
Tesseratus adopts a multi-agent approach to define a hybrid model to predict the glucose oscillation for up to four hours during daytime and for up to eight hours at the night period. It is a hybrid model because agents are defined using both compartment models (described in Section 2.1) and data-driven techniques, such as machine learning (ML). Tesseratus has two types of agents: reactive agents and intelligent agents. Nevertheless, we decomposed the problem in such a way that each agent is responsible for a portion of the phenomenon [47], which means that there are several agents of each type. The reactive agents are responsible for collecting data and feeding intelligent agents with the collected data or for monitoring data, error and ODE parameters. Intelligent agents are responsible for using data to predict the glucose oscillation. The intelligent agents are: the Recommender agent, the Predictor agent, the ML agent and the Math agent. The Recommender agent has a knowledge base composed of labeled glucose oscillation prediction curves (within the range or out of range--following a semaphore metaphor) and is responsible for finding and labeling suitable curves for received data and delivering them to the user. The Predictor agent has a knowledge base of labeled predicted values and actions and is responsible for asking the Math and ML agents for information to populate its knowledge base and for providing glucose oscillation prediction curves to the Recommender agent. The Math agent has the math modeling presented in Section 2.1 as the core for the generation of glucose oscillation prediction curves, and the ML agent learns the glucose oscillation prediction curves from the combination of received data provided by reactive agents and by the Math agent. Communication is bidirectional between intelligent agents. The Predictor agent communicates with all intelligent agents, and the ML agent communicates with the Predictor and Math agents. Reactive agents only send messages to intelligent agents. Having received these messages, intelligent agents act accordingly to recommend a glucose oscillation prediction curve or to adapt the recommendation given the monitored context (prediction error above a threshold, the need for updating ODE parameters or non-conformance of collected data as expected). Tesseratus innovates in the problem solution by adopting a learning policy that considers both information from the individuals collected data and from the mathematical modeling. Therefore, at the very beginning, we defined a set-up step for knowledge acquisition and data labeling. In this step, the Math agent generates glucose values and associated labeling, providing information to accelerate the learning using the generated glucose values and associate labeling, and the ML agent reuses knowledge from the Math agent. All intelligent agents knowledge bases are built in a continuous reinforcement learning cycle that begins with the Math agent knowledge combined with a reward policy based on the semaphore metaphor. Data are labeled green, yellow or red depending on the glucose concentration and the absolute error, both within pre-established thresholds. The reader may observe in Table 2 that there are two rewards labeled as green and two other rewards labeled as red because excellent and normal glucose levels associated with an absolute error smaller than 30 mg/dL are labeled as green, depending on the PH; and hyperglycemia and hypoglycemia levels are labeled as red, as well as an absolute error bigger than 30 mg/dL. For the red label, the reward should be considered if at least one of the situations occur. An acceptable glucose concentration is labeled as yellow. By absolute error, we mean the error between the measured and predicted glucose values. The architecture of Tesseratus is presented in Figure 3, where numbers are adopted to support its explanation flow. 1. Reactive agents collect data from continuous glucose monitors (CGM), voice or manually, and send them to the Recommender agent;
2.