## Modeling

The library supports the modeling of deterministic dynamical systems both at continuous and at discrete time.

MP modeling is obtained by suitable MP grammars. Each MP grammar consists of a set of *variables*, which represent significant quantities of the model and a set of *rules*, as in the following example:

Each rule is defined by:

- a
*reaction*that specifies variable introduction/transformation/expulsion (using standard arrow notation); - a
*regulator*that is a formula for computing the speed of the reaction (i.e. how much of the variables are transformed by reactions at each simulation step).

For example, in the MP grammar depicted above there are five rules over three variables (A, B, and C). The first rule introduces matter of type A in the system, rules one and two apply some transformations and the last two rules expel matter of type B and C, respectively.

Regulators permit the computation of the amounts that are consumed/produced by reactions at each step. According to the type of the system, regulators are used according to different strategies (see the documentation for details). The simpler way of considering regulators is that implemented in *MPF systems* (MP systems with fluxes), where regulators directly compute the fluxes of rules in the current state.

For example, if in the current state the variable A has a value of 5, then the flux of the rule zero in the example above is computed by 0.047+0.087·5 = 0.482. Therefore, in the next step the value of variable A will be increased by rule zero of this amount.

The modeling experience offered by the library is enhanced by the simplicity of the implemented objects. The following code, for example, creates an MP grammar like that provided above in a way that is really close to its definition:

Once a model has been created, the simulation and the plot of the computed dynamics can be obtained with few lines of code. The following chart, for example, depicts the first 1000 steps of the dynamics given by the MP grammar discussed above, starting from an initial value of 100 for A and B and from an initial value of 0 for C.

## Regression

Simulating a model could be important for understanding the behavior of a system. However, the most of the times the knowledge about a phenomenon is soo low, that it is difficult to model it only by considering previous knowledge (available in literature) and suitable hypotheses. In particular, it is difficult to find regulator formulae, because they provide the internal logic of reaction regulations that is behind the observed phenomenon.

Usually, researchers start from a set of observations, which provide the dynamics of a phenomenon, and they aim at defining a dynamical system that explains the logic behind the observed behavior. This logic, in MP models, is given by regulator formulae.

The library supports different regression strategies that permit, in a very simple way, to infer regulator formulae starting from a set of reactions and time series of observations. The general schema of regression could be shortly resumed by the following picture:

The user guide of the library comprises a 50 pag. chapter entirely devoted to the process of inferring MP models. The implemented strategies range from brand new techniques explicitly developed withing the MP theory (such as the Log-gain Stepwise regression, see references) to state of the art non-linear optimization techniques like CMA-ES (a stochastic evolutionary algorithm) and BOBYQA (an iterative procedure particularly well suited for high dimensional problems).

All the implemented algorithms can be customized and support multi-threading. Moreover, results are equipped with additional measures for evaluating the reliability of inferred models according to statistics (conﬁdence interval and standard deviation of regression parameters, error estimates, and Pearson correlations are provided for each model). Models can also be compared according to the information theory Akaike criterion (AIC, standard and corrected one) and according to the Bayesian information criterion (BIC).