# Mathematical Description¶ This mathematical description refers to the beginnings of the model and explains its basic constraints. In order to get information about the current MAgPIE versions it is recommended to read the corresponding model documentations instead.

## Introduction¶

MAgPIE (Model of Agricultural Production and its Impact on the Environment) is a nonlinear recursive dynamic optimization model that links regional economic information with grid-based biophysical constraints simulated by the dynamic vegetation model LPJmL. A simulation run with the simulation period $T$ can be described as a set

\begin{align}
X = \left\{x_t \mid t \in T \right\} \subseteq \Omega
\end{align}

of solutions of a time depending minimization problem, i.e. for every timestep $t \in T$ the following constraint is fulfilled

\begin{align}
\forall y \in \Omega : g_t(x_t) \leq g_t(y)
\end{align}

where the goal function for $t \in T$

\begin{align}
g_t(x_t) = g(t,x_t,x_{(t-1)},...,x_1,P_t)
\end{align}

depends on the solutions of the previous time steps $x_{(t-1)},...,x_1$ and a set of time depending parameters $P_t$. We may interprete a MAgPIE simulation run $X = \left\{x_t \mid t \in T \right\} \subseteq \Omega$ as an element of the vector space $\Omega_T = \Omega \times T$.

## Sets¶

The dimension of the domain $\Omega$, on which for each timestep the minimization problem is defined, and of $\Omega_T$ depends on the following sets:

• $T = \{ \text{time steps } t\}$: Simulation time steps, where $t$ denotes the current time step, $t-1$ the previous time step and so on. The first simulated time step is $t=1$.
• $I = \{ \text{world regions } i\}$: Economic world regions in MAgPIE.
• $J = \{ \text{spatial clusters } j \}$ : Highest spatial disaggregation level in MAgPIE.
• $K = \{ \text{simulated products } k\}$ : Union of vegetal products $V$ and livestock products $L$ ($K = V\cup L$).
• $L = \{ \text{simulated livestock products } l\}$: Products simulated within the livestock sector of MAgPIE.
• $V = \{ \text{vegetal products } v\}$: Products simulated within the crop sector of MAgPIE.
• $W = \{ \text{water supply types } w\}$: Currently two types are implemented: rainfed 'rf' and irrigated 'ir'
• $C = \{ \text{crop rotation groups } c\}$: Groups of crops, which have similar requirements concerning crop rotation criteria.

To highlight the substance of our model equations with regard to the agricultural and economic contents, we split our variable $x_t$ into

\begin{align}
x_t = \left( x^{area}_t \in \Omega^{area}, x^{prod}_t \in \Omega^{prod}, x^{tc}_t \in \Omega^{tc} \right) \in \Omega
\end{align}

where the respective domains can be identified as the following vector spaces

\begin{align}
\Omega^{area} &= \mathbb{R}^{|J|}\times\mathbb{R}^{|V|}\times\mathbb{R}^{|W|} \\
\Omega^{prod} &= \mathbb{R}^{|J|}\times\mathbb{R}^{|L|} \\
\Omega^{tc} &= \mathbb{R}^{|I|}
\end{align}

As a result, we may specify the dimension of the solution space for each timestep as $dim \Omega = |J|\cdot|V|\cdot|W| + |J|\cdot|L| + |I|$ and the dimension of $\Omega_T = \Omega \times T$ as $dim \Omega_T = |T|\cdot dim \Omega = |T|\cdot\left(|J|\cdot|V|\cdot|W| + |J|\cdot|L| + |I|\right)$.

In the following, variables and parameters are provided with subscripts to indicate the dimension of the respective subdomains. Subscripts written in quotes are single elements of a set. The order of subscripts in the variable, parameter and function definitions does not change. The names of variables and parameters are written as superscript.

## Variables¶

Since MAgPIE is a recursive dynamic optimization model, all variables refer to a certain time step $t \in T$. In each optimization step, only the variables belonging to the current time step are free variables. For all previous time steps, values were fixed in earlier optimization steps. As we have seen above, we currently distinguish three variables $x^{area}_t \in \Omega^{area}$, $x^{prod}_t \in \Omega^{prod}$ and $x^{tc}_t \in \Omega^{tc}$ that can be described as follows:

• $x^{area}_{t,j,v,w}$ : The total area of each vegetal production activity $v$ for each water supply type $w$, each cluster $j$ and each time step $t$ [$10^6$ ha]
• $x^{prod}_{t,j,l}$: The total production of each livestock product $l$, for each cluster $j$ at each time step $t$ [$10^6$ton dry matter]
• $x^{tc}_{t,i}$: The amount of yield growth triggered by investments in R&D [-]

## Parameters¶

Besides variables, the model is fed with a set of parameters $P_t$. These parameters are computed exogenously and are in contrast to variables of previous time steps fully independent of any simulation output. Although most parameters are time independent, there exist also some parameters which are time dependent.

• $p^{yield}_{t,j,v,w}$: Yield potentials for each time step, each cluster, each crop and each water supply type taking only biophysical variations into account and excluding changes due to technological change [ton/ha]
• $p^{dem}_{t,i,k}$: Regional food and material demand in each time step for each product [$10^6$ ton]
• $p^{fbask}_{i,l,k}$: Feed basket parameter describing the feed basket of products $k$ required to produce one livestock product $l$ [ton/ton]
• $p^{frv}_{i,v}$: Area related factor requirements for each crop and each region based on the technological development level in the initial time step [US$/ha] •$p^{frl}_{i,l}$: Production related factor requirements for livestock products for each livestock type and each region [US$/ton]
• $p^{lcc}_i$: Area related land conversion costs for each region [US$/ha] •$p^{tcc}$: Technological change cost factor accounting for interest rate, expected lifetime and general costs [US$/ha]
• $p^{\tau1}_{i,v}$: $\tau$-Factor representing the agricultural land use intensity in the first simulation time step for each crop in each region [-]
• $p^{cxp}$: Correlation Exponent between $\tau$-Factor and technological change costs [-]
• $p^{seed}_{i,v}$: Share of production that is used as seed for the next period calculated for each crop in each region [-]
• $p^{xs}_{t,i,k}$: Regional excess supply for each product and each time step describing the amount produced for export [$10^6$ ton]
• $p^{sf}_{i,k}$: Regional self sufficiencies for each product [-]
• $p^{tb}$: Trade balance reduction factor with $0\leq p^{tb} \leq 1$ which is used to relax the trade balance constraints depending on the particular trade scenario.
• $p_{j}^{land}$: Total amount of land available for crop production in each cluster [$10^6$ ha]
• $p^{ir.land}_j$: Total amount of land equipped for irrigation in each cluster [$10^6$ ha]
• $p^{watreq}_{j,k}$: Cluster-specific water requirements for each product [$m^{3}/ton/a$]
• $p^{water}_j$: Amount of water available for irrigation in each cluster [$m^{3}/a$]
• $p^{rmax}_c$: Maximum share of crop groups in relation to total agricultural area [-]
• $p^{rmin}_c$: Minimum share of crop groups in relation to total agricultural area [-]

[all ton units are in dry matter]

## Sub-Functions¶

To simplify the general model structure, some model components which appear more than once in the model description and depend on the variables of the current time step $t$ are arranged as functions:

\begin{align}
&f_{t,i}^{growth}(x_t) = \prod_{\tau=1}^{t}{(1+x^{tc}_{\tau,i})} \\
&f^{prod}_{t,i,k}(x_t) = \sum_{j_i}
\begin{cases}
x^{prod}_{t,j,k} &: k \in L \\
\sum_{w}x^{area}_{t,j,k,w}p^{yield}_{t,j,k,w}f_{t,i}^{growth}(x_t) &: k \in V
\end{cases} \\
&f^{dem}_{t,i,k}(x_t) = p^{dem}_{t,i,k} + p^{seed}_{i,k} * f^{prod}_{t,i,k}(x_t)+
\end{align}

• $f_{t,i}^{growth}$: Growth function describing the aggregated yield amplification due to technological change compared to the level in the starting year for each year $t$ and region $i$.
• $f^{prod}_{t,i,k}$: Function representing the total regional production of a product $k$ in region $i$ at timestep $t$. In the case of vegetal products, it is derived by multiplying the current yield level with the total area used to produce this product. In the case of livestock products, it is represented by the related production variable.
• $f^{dem}_{t,i,k}$: Function defining the demand for product $k$ in region $i$ at timestep $t$. It consists of an exogenous demand for food and materials $p^{dem}_{t,i,k}$ and an endogenous demand for feed, which is calculated as the feed demand generated by the livestock production minus the feed supply gained through byproducts.

## Goal Function¶

\begin{align}
g_t(x_t) &= g(t,x_t,x_{(t-1)},...,x_1,P_t)
\end{align}

The goal function describes the value that is minimized in our recursive dynamic optimization model structure in each timestep. It is time dependent, i.e. it differs for each time step, depending on the solutions of the previous time steps. We define the goal function as follows (with $\Theta(x)$ as Heaviside step function):

\begin{align}
g_t(x_t) = &\sum_{i,v}\left(p^{frv}_{i,v}f_{t,i}^{growth}(x_t)\sum_{j_i,w}x^{area}_{t,j,v,w}\right) \\
+ &\sum_{i,l}\left(p^{frl}_{i,l}f^{prod}_{t,i,l}(x_t)\right) \\
+ &\sum_i\left(p^{lcc}_i\sum_{j_i,v,w}{\left(x^{area}_{t,j,v,w}-x^{area}_{t-1,j,v,w}\right)}\Theta\left(x^{area}_{t,j,v,w}-x^{area}_{t-1,j,v,w}\right)\right) \\
+ &p^{tcc}\sum_i\left(x^{tc}_{t,i}\left(\frac{1}{|V|}\sum_{v} p^{\tau1}_{i,v} f_{t,i}^{growth}(x_t)\right)^{p^{cxp}} \sum_{j_i,v,w}{x^{area}_{t-1,j,v,w}}\right) .
\end{align}

The function describes the total costs of agricultural production. The total costs can be split in four terms: 1. area depending factor costs of vegetal production, which increase with the yield gain due to technological change; 2. factor costs of livestock production depending on the production output; 3. land conversion costs which arise, when non-agricultural land is cleared and prepared for agricultural production; 4. investment costs in technological change to increase yields by improvements in management strategies and other inventions. The technological change costs are proportional to total cropland area of a region and increase disproportionately with yield growth bought in the current timestep and the agricultural land-use intensity.

## Constraints¶

Constraints describe the boundary conditions, under which the goal function is minimized.

### Global demand constraints¶

(for each activity k)

\begin{align}
\sum_i{f^{prod}_{t,i,k}(x_t)} &\geq \sum_i{f^{dem}_{t,i,k}(x_t)}
\end{align}

These constraints describe global demand for agricultural commodities: Total production of a commodity $k$ adjusted by the seed share required for the next production iteration has to meet the demand for this product.

(for each region i and product k)

\begin{align}
f^{prod}_{t,i,k}(x_t) \geq p^{tb}
\begin{cases}
f^{dem}_{t,i,k}(x_t) + p^{xs}_{t,i,k} &: p^{sf}_{i,k} \geq 1 \\
f^{dem}_{t,i,k}(x_t)p^{sf}_{i,k} &: p^{sf}_{i,k} < 1
\end{cases}
\end{align}

The trade balance constraints are similar to the global demand constraints, except that they act on a regional level. In the case of an exporting region (self sufficiency for the product $k$ is greater than 1), the production has to meet the domestic demand supplemented by the demand caused due to export. In the case of importing regions (self sufficiency less than 1), the domestic demand is multiplied with the self sufficiency to describe the amount which has to be produced by the region itself. In both cases the demand is multiplied with a so called "trade balance reduction factor". This factor is always less than or equal to 1 and is used to relax the trade balance constraints depending on the particular trade scenario for the future.

### Land constraints¶

(for each cluster j)

\begin{align}
\sum_{v,w}x^{area}_{t,j,v,w} &\leq p_{j}^{land} \\
\sum_{v}{x^{area}_{t,j,v,'ir'}} &\leq p^{ir.land}_j
\end{align}

The land constraints guarantee that no more land is used for production than available. The first set of land constraints ensures the land availability for agricultural production in general. The second one secures that irrigated crop production is restricted to areas that are equipped for irrigation.

### Water constraints¶

(for each cluster j)

\begin{align}
\sum_{v}{x^{area}_{t,j,v,'ir'}p^{yield}_{t,j,v,'ir'}f_{t,i(j)}^{growth}(x_t) p^{watreq}_{j,v}} + \sum_{l}{x^{prod}_{t,j,l}p^{watreq}_{j,l}} \leq p^{water}_j
\end{align}

The output of animal products as well as vegetal products under irrigated conditions requires water. The required amount of water is proportional to the production volume. The whole water demand in each cluster must be less or equal to the water available for production in this cluster.

### Rotational constraints¶

(for each crop rotation group c, cluster j and irrigation type w)

\begin{align}
\sum_{v_c}{x^{area}_{t,j,v,w}} \leq p^{rmax}_c \sum_{v}{x^{area}_{t,j,v,w}} \\
\sum_{v_c}{x^{area}_{t,j,v,w}} \geq p^{rmin}_c \sum_{v}{x^{area}_{t,j,v,w}}
\end{align}

The rotational constraints are used to prescribe typical crop rotations by defining for each vegetal product a maximum and minimum share relative to total area under production in a cluster.