Skip to main content
Log in

Optimizing pig marketing decisions under price fluctuations

  • S.I.: Agriculture Analytics, BigData and Sustainable Development
  • Published:
Annals of Operations Research Aims and scope Submit manuscript

Abstract

In the manufacturing of fattening pigs, pig marketing refers to a sequence of culling decisions until the production unit is empty. The profit of a production unit is highly dependent on the price of pork, the cost of feeding and the cost of buying piglets. Price fluctuations in the market consequently influence the profit, and the optimal marketing decisions may change under different price conditions. Most studies have considered pig marketing under constant price conditions. However, because price fluctuations have an influence on profit and optimal marketing decisions it is relevant to consider pig marketing under price fluctuations. In this paper we formulate a hierarchical Markov decision process with two levels which model sequential marketing decisions under price fluctuations in a pig pen. The state of the system is based on information about pork, piglet and feed prices. Moreover, the information is updated using a Bayesian approach and embedded into the hierarchical Markov decision process. The optimal policy is analyzed under different patterns of price fluctuations. We also assess the value of including price information into the model.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5

Similar content being viewed by others

Notes

  1. Danish pig feed unit (1 FEsv = 7.72 MJ).

  2. Using shared and external processes, i.e. the memory of child processes may be shared and loaded when needed. For further information see the documentation in Nielsen (2009).

  3. http://www.danishcrown.dk/Ejer/Noteringer/Aktuel-svinenotering.aspx (October 2015).

References

Download references

Acknowledgements

This article has been written with support from The Danish Council for Strategic Research (The PigIT Project, Grant No. 11-116191). We would like to thank the two anonymous referees for improving this paper.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Lars Relund Nielsen.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendices

Notation

Because the paper uses techniques from both statistical forecasting and operations research, we have to make some choices with respect to notation. In general, we use capital letters for matrices and let \( A' \) denote the transpose of A. Capital blackboard bold letters are used for sets (e.g., \( \mathbb {P}_{} \) and \( \mathbb {D}_{n^{}} \)). Finally, accent \({\hat{x}}\) (hat) is used to denote an estimate of x. A description of the notation introduced in Sects. 2 and 3 is given in Tables 4 and 5, respectively.

Table 4 Notation-HMDP model (Sect. 2)
Table 5 Notation-state space models (Sect. 3)

Calculating expected reward

1.1 Modeling weights in the pen

During the growing period in the pen, pigs grow at different rates; that is, given a certain week in the production cycle, there are variation between the weights of the individual animals in the pen. Moreover, as the pigs grow, the variation increases and our uncertainty about the average weight of the pen increases.

Let \((w_{(1)},\ldots ,w_{(k)},\ldots ,w_{(q)})_{t}\) denote the weight distribution of the \( q\) pigs in the pen at week t such that \(w_{(1)}\), \(w_{(k)}\), and \(w_{(q)}\) are ordered random variables (order statistics) related to the weight of the lightest, kth lightest and the heaviest pig in the pen at stage \(n^{}\), respectively. To find the probability distribution of the ordered random variable \(w_{(k)}\), first the weight distribution of a randomly selected pig should be determined in the pen. To specify this distribution, we use a random regression model (RRM), often applied in the animal breeding models (Schaeffer 2004).

Let \(w_{j,t}\) denote the weight of a randomly selected pig j in week t described using an RRM:

$$\begin{aligned} w_{j,t} = X_{t}\beta _{} + Z_{t}\alpha _{j} + \varepsilon _{j,t}, \end{aligned}$$
(15)

where \(X_{t}\) and \(Z_{t}\) are time covariate vectors, \(\beta _{}\) is the vector of fixed parameters, \(\alpha _{j}\) is the vector of random parameters and \(\varepsilon _{j,t}\) is a residual error. In this RRM, \(X_{t}\beta _{}\) is the fixed effect of the model representing the average weight of the pen and \(Z_{t}\alpha _{j}\) is the random effect showing a deviation between the weight of pig j and the average weight of the pen. A quadratic RRM is used suggested by Cai et al. (2011) where \(X_{t}=Z_{t}=\begin{pmatrix}1&\quad t&\quad t^2\end{pmatrix}\), \(\alpha _{j} = \begin{pmatrix} \alpha _{0j}&\quad \alpha _{1j}&\quad \alpha _{2j} \end{pmatrix}'\) and \(\beta = \begin{pmatrix} \beta _{0}&\quad \beta _{1}&\quad \beta _{2} \end{pmatrix}'\):

$$\begin{aligned} w_{j,t} = \beta _{0} + \beta _{1} t + \beta _{2} t^2 + \alpha _{0j} + \alpha _{1j} t + \alpha _{2j} t^2 + \varepsilon _{j,t}. \end{aligned}$$

Random parameter \(\alpha _{j}\) follows a normal distribution with parameters

$$\begin{aligned} \alpha _{j}=\begin{pmatrix} \alpha _{0j} \\ \alpha _{1j} \\ \alpha _{2j} \end{pmatrix} \sim N\left( 0, V= \begin{pmatrix} \sigma _{0}^2 &{}\quad \sigma _{01} &{}\quad \sigma _{02} \\ \sigma _{01} &{}\quad \sigma _{1}^2 &{}\quad \sigma _{12} \\ \sigma _{02} &{}\quad \sigma _{12} &{}\quad \sigma _{2}^2 \\ \end{pmatrix} \right) , \end{aligned}$$

where \(V\) is independent of pig j and time t. Moreover, the residual errors \(\varepsilon _{j,t} \sim N\left( 0,\;R\right) \) are independent random variables. Because (15) is linear with respect to random parameters \(\alpha _{j}\) and \(\varepsilon _{j,t}\), we can conclude

$$\begin{aligned} w_{j,t} \sim N\left( \mu _{t} = X_{t}\beta _{},\;\sigma _{t}^2= Z_{t}VZ_{t}' + R)\right) . \end{aligned}$$
(16)

The parameters \(\beta _{}\), \(V\) and \(R\) can be estimated using the restricted maximum likelihood (REML) method (Patterson and Thompson 1971).

Because the probability distribution of \(w_{j,t}\) is independent of pig j, the weight distribution of all \(q\) pigs in the pen are i.i.d at time t. Hence, the probability density function of the ordered random variable \(w_{(k)}\) becomes

$$\begin{aligned} \phi _{(k)}(w) = \frac{q!}{(k-1)!(q-k)!}\varPhi ^{k-1}(w)[1-\varPhi (w)]^{q-k}\phi (w), \end{aligned}$$

where \(\varPhi (w)\) and \(\phi (w)\) are the cumulative and density functions of the normal distribution defined in (16) (Pitmand 1993, p. 326).

1.2 Carcass weight, leanness, feed intake and growth

Consider the kth lightest pig at stage n with weight \(w\) and daily growth \( g\). The carcass weight \({\tilde{w}}_{}\) can be approximated as

$$\begin{aligned} {\tilde{w}}_{}=c_sw- 5.89 + e_{\texttt {\small c}}, \end{aligned}$$
(17)

where \(e_{\texttt {\small c}}\sim N(0, \sigma _c^2)\) (Andersen et al. 1999). The relation between growth rate, leanness (lean meat percentage) and feed conversion ratio varies widely between herds. Hence, these formulas must be herd specific. The leanness \(\breve{w}_{}\) can be found as

$$\begin{aligned} \breve{w}_{}=\frac{-30(g-{\bar{g}})}{4} + {\bar{\breve{w}_{}}}, \end{aligned}$$
(18)

where \({\bar{g}}\) is the average daily growth in the herd and \({\bar{\breve{w}_{}}}\) is the average herd leanness percentage (Kristensen et al. 2012).

The feed intake (energy intake) is modelled as the sum of feed for maintenance and feed for growth. The basic relation between daily feed intake \( f\) (FEsv), live weight and daily gain is

$$\begin{aligned} f= k_1 g+ k_2 w^{0.75}, \end{aligned}$$
(19)

where \( k_1 \) and \( k_2 \) are constants describing the use of feed per kilogram gain and per kilogram metabolic weight, respectively (Jørgensen 2003). As a result the expected feed intake of a pig over the next \( {\hat{t}} \) days equals

$$\begin{aligned} f^{\scriptscriptstyle \texttt {feed}}_{(k),n^{}}({\hat{t}})= & {} {\mathbb {E}}\left( \sum _{t=1}^{{\hat{t}}} f_t \right) = {\mathbb {E}}\left( \sum _{t=1}^{{\hat{t}}} \left( k_1g+ k_2(w+(t-1)g)^{0.75} \right) \right) \nonumber \\= & {} {\mathbb {E}}\left( {\hat{t}}k_1g+ k_2\sum _{t=1}^{{\hat{t}}}(w+(t-1)g)^{0.75} \right) , \end{aligned}$$
(20)

where \( f_t \) denotes the feed intake on day t calculated recursively using (19).

1.3 Settlement pork price

Consider the kth lightest pig at stage n with carcass weight \({\tilde{w}}_{}\) and leanness \( \breve{w}_{}\) at delivery. The settlement pork price, under Danish conditions, is the sum of two linear piecewise functions related to the price of the carcass and a bonus of the leanness:

$$\begin{aligned} p^{\scriptscriptstyle \texttt {pork}}_{(k),n^{}}({\tilde{w}}_{},\breve{w}_{}) = \tilde{p}({\tilde{w}}_{},p_{}^{\texttt {pork}}) + \breve{p}(\breve{w}_{}), \end{aligned}$$
(21)

where \( p_{}^{\texttt {pork}} \) is the current pork price at the market. Functions \(\tilde{p}({\tilde{w}}_{},p_{}^{\texttt {pork}})\) and \(\breve{p}(\breve{w}_{})\) correspond to the unit price of carcass and the bonus of leanness for 1 kg meat, respectively. A plot of each function is given in Fig. 6.

Given the price structure, based on the Danish slaughter pig market,Footnote 3 the unit price of 1 kg carcass is

That is, the market pork price \(p_{}^{\texttt {pork}}\) may be interpreted as the maximum price of 1 kg carcass that can be obtained (when the carcass weight lies between 70 and 95 kg).

The bonus of leanness is calculated as

Fig. 6
figure 6

Price functions (DKK/kg) given carcass weight and leanness

1.4 Calculation of expected values

The calculations of the expected values (6)–(9) is rather complex due to the ordered random variables and the non-continuous functions \( \tilde{p}({\tilde{w}}_{},p_{}^{\texttt {pork}}) \) and \( \breve{p}(\breve{w}_{}) \). However, the expectations can be calculated using simulation with a simple sorting procedure as described below.

  1. Step 0

    For each pig \( j=1,\ldots q^{\max }\), draw random vector \( \alpha _{j}\sim N\left( 0,\;V\right) \).

  2. Step 1

    For each week t and pig j, draw residual \(\varepsilon _{j,t} \sim N\left( 0,\;R\right) \) and find weight

    $$\begin{aligned} w_{j,t} = X_{t}\beta _{} + Z_{t}\alpha _{j} + \varepsilon _{j,t}. \end{aligned}$$

    Moreover, use the weights to find the daily growth \( g\) during a week.

  3. Step 2

    For each week t and pig j, use (17) and (18) to find the carcass weight and leanness (\( b\) days ahead), respectively. Moreover, use (19) to find the feed intake for the next \( t=7 \) and \( b\) days, i.e., (20) is calculated.

  4. Step 3

    For each week t, pig j and possible center point of pork price, calculate the settlement pork price (21).

  5. Step 4

    For each week t, sort the obtained values of feed intake and settlement pork price in non-decreasing order of weight.

We run the simulation 10,000 times to calculate average values of the feed intake and settlement pork price and next use the values to calculate the expected values (6)–(9).

Bayesian updating of SSMs

An SSM includes a set of observable and latent/unobservable continuous variables. The set of latent variables \(\theta _{\{t=0,1,\ldots \}}\) evolves over time using system equation (written using matrix notation)

$$\begin{aligned} \theta _{t} = G_{t}\theta _{t-1}+\omega _{t}, \end{aligned}$$
(22)

where \(\omega _t\sim N\left( 0,W_{t}\right) \) is a random term and \(G_{t}\) is a matrix of known values. We assume that the prior \(\theta _{0}\sim N(m_{0},C_{0})\) is given. Moreover, we have a set of observable variables \(y_{\{t=1,2,\ldots \}}\) (time-series data of prices) which are dependent on the latent variable using observation equation

$$\begin{aligned} y_{t} = F_{t}'\theta _{t}+\nu _{t}, \end{aligned}$$
(23)

with \(\nu _t\sim N\left( 0,V_{t}\right) \). Here \( F_{t} \) is the design matrix of system equations with known values and \( F' \) denote the transpose of matrix F. The error sequences \(\omega _t\) and \(\nu _t\) are internally and mutually independent. Hence given \(\theta _{t}\) we have that \(y_{t}\) is independent of all other observations and in general the past and the future are independent given the present.

Let \({\mathbb {D}}_{t-1}=(y_{1},\ldots ,y_{t-1},m_{0},C_{0})\) denote the information available up to time \(t-1\). Given the posterior of the latent variable at time \(t-1\), we can use Bayesian updating (the Kalman filter) to update the distributions at time t (West and Harrison 1997, Theorem 4.1).

Theorem 1

Suppose that at time \(t-1\) we have

$$\begin{aligned} \left( \theta _{t-1}\mid {\mathbb {D}}_{t-1}\right) \sim N\left( m_{t-1},C_{t-1}\right) ,\quad \text {(posterior at time}\,t-1\text {).} \end{aligned}$$

then

$$\begin{aligned} \begin{aligned} \left( \theta _{t}\mid {\mathbb {D}}_{t-1}\right)&\sim N\left( a_{t},R_{t}\right) ,&\quad&\text {(one-step state distribution)}\\ \left( y_{t}\mid {\mathbb {D}}_{t-1}\right)&\sim N\left( f_{t},Q_{t}\right) ,&\quad&\text {(one-step forecast distribution)}\\ \left( \theta _{t}\mid {\mathbb {D}}_{t}\right)&\sim N\left( m_{t},C_{t}\right) ,&\quad&(\hbox {posterior at time}\,\,t) \end{aligned} \end{aligned}$$

where

$$\begin{aligned} \begin{aligned} a_{t}&= G_{t}m_{t-1},&R_{t}&= G_{t}C_{t-1}G_{t}^{\prime }+W_{t} \\ f_{t}&= F_{t}^{\prime }a_{t},&Q_{t}&= F_{t}^{\prime }R_{t}F_{t}+V_{t}\\ e_{t}&= y_{t}-f_{t},&A_{t}&= R_{t}F_{t}Q_{t}^{-1} \\ m_{t}&= a_{t}+A_{t}e_{t},&C_{t}&= R_{t}-A_{t}Q_{t}A_{t}^{\prime }. \end{aligned} \end{aligned}$$

Note that the means of the one-step state and forecast distributions, \(a_t\) and \(f_{t}\), only depend on \(m_{t-1}\). Moreover variance \(C_t\) only depends on the number of observations made, i.e., we can calculate it without knowing the observations \(y_{1},\ldots ,y_{t}\). Similarly, we can find k-step conditional distributions.

Theorem 2

Suppose that at time t we have

$$\begin{aligned} \left( \theta _{t}\mid {\mathbb {D}}_{t}\right) \sim N\left( m_{t},C_{t}\right) ,\quad \text {(posterior at time }t\text {).} \end{aligned}$$

then

$$\begin{aligned} \begin{aligned} \left( y_{t+k} | m_{t}\right) = \left( y_{t+k}\mid {\mathbb {D}}_{t}\right)&\sim N\left( f_t(k),Q_t(k) \right) ,&\quad&\text {(k-step forecast distribution)}\\ \left( m_{t+k} | m_{t}\right) = \left( m_{t+k} | {\mathbb {D}}_{t}\right)&\sim N\left( a_t(k),A_t(k)Q_t(k)A'_t(k) \right) ,&\quad&\text {(k-step posterior mean distribution}) \end{aligned} \end{aligned}$$

where \( f_t(k) = F_{t+k}'a_t(k) \), \( Q_t(k) = F_{t+k}'R_t(k)F_{t+k} + V_{t+k} \) and \( A_t(k) = R_t(k)F_{t+k}Q_t(k)^{-1} \) which can be recursively calculated using

$$\begin{aligned} a_t(k)&= G_{t+k}a_t(k-1), \\ R_t(k)&= G_{t+k}R_t(k-1)G_{t+k}' + W_{t+k}, \end{aligned}$$

with starting values \(a_t(0)=m_{t}\) and \(R_t(0)=C_{t}\).

Proof

First, note that the probability distribution of \((y_{t+k} | {\mathbb {D}}_{t})\) and the related proof have been given in West and Harrison (1997, Theorem 4.2). Moreover, because \( f_t(k) \) is a function of \( m_t \), we have that \( \left( y_{t+k}\mid {\mathbb {D}}_{t}\right) = \left( y_{t+k} | m_{t}\right) \).

Next, to find the probability distribution of \((m_{t+k} | {\mathbb {D}}_{t})\), we use the similar procedure given in the proof of Theorem 4.2 in West and Harrison (1997, pp. 107–108). According to the repeated application of system equation in an SSM (West and Harrison 1997, p. 107), the k-step evolution of latent variable \(\theta _t\) can be formulated as

$$\begin{aligned} \theta _{t+k} = G_{t+k}(k)\theta _t + \sum _{r=1}^{k}G_{t+k}(k-r)\omega _{t+r}, \end{aligned}$$
(24)

where \(G_{t+k}(r)=G_{t+k}G_{t+k-1},\ldots ,G_{t+k-r+1}\) for \(r<k\), with \(G_{t+k}(0)=I\). Now, using (22)–(24), we can generate an SSM modelling the k-step evolution of \(\theta _t\):

$$\begin{aligned} \begin{aligned}&\text {Observation equation: } \; y_{t+k} = F_{t+k}' \theta _{t+k}+\nu _{t+k} \\&\text {System equation: } \; \theta _{t+k} = G_{t+k}(k)\theta _t + \sum _{r=1}^{k}G_{t+k}(k-r)\omega _{t+r}. \end{aligned} \end{aligned}$$

For this SSM we can use the general properties of Theorem 1 with \(t-1\), t, \(G_t\) and \(\omega _t\) replaced with t, \(t+k\), \(G_{t+k}(k)\) and \(\sum _{r=1}^{k}G_{t+k}(k-r)\omega _{t+r}\), respectively. Hence

$$\begin{aligned} m_{t+k} = a_{t}(k)+A_{t}(k)e_{t}(k), \end{aligned}$$

where

$$\begin{aligned} a_{t}(k) = G_{t+k}(k)m_{t}, \quad e_{t}(k) = y_{t+k}-f_{t}(k). \end{aligned}$$

Based on these equations and \((y_{t+k}|m_t)\sim N( f_t(k),Q_t(k))\), we have that

$$\begin{aligned} (m_{t+k}|m_t) \sim N(a_t(k),A_t(k)Q_t(k)A_t(k)^{\prime }), \end{aligned}$$

where based on the recursive equation for \(G_{t+k}(r)\) and Theorem 1, we have that

$$\begin{aligned} a_t(k)&= G_{t+k}(k)m_t = G_{t+k}a_t(k-1),\\ R_t(k)&= G_{t+k}(k)C_tG_{t+k}^{\prime } + \sum _{r=1}^{k} G_{t+k}(k-r)W_{t+r}G_{t+k}(k-r)^{\prime }\\&= G_{t+k}R_t(k-1)G_{t+k}^{\prime } + W_{t+k}, \\ A_t(k)&= R_t(k)F_{t+k}Q_t(k)^{-1}, \\ Q_t(k)&= F_{t+k}'R_t(k)F_{t+k} + V_{t+k}. \end{aligned}$$

\(\square \)

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Pourmoayed, R., Relund Nielsen, L. Optimizing pig marketing decisions under price fluctuations. Ann Oper Res 314, 617–644 (2022). https://doi.org/10.1007/s10479-020-03646-0

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10479-020-03646-0

Keywords

Navigation