# Production Optimization in a Grain Facility through Mixed-Integer Linear Programming +
## 3 The Grain Facility Optimization Problem
Parameter \(\tau\) denotes the shelf life of products that expire (measured in weeks). 5. Parameter \(N\) denotes the maximum number of shifts per week. 6. Parameter \(H_{f}\) denotes the number of productive hours in a shift. 7. Parameter \(\pi_{I}\) denotes the productivity of the production line \(l\in L\) (measured in tons/h). 8. Parameter \(L_{I}\) denotes the cleaning time of line \(l\in L\) (measured in hours). 9. Parameter \(B_{v}\) denotes the number of batches of product \(v\); in case \(v\in V_{I}\), if \(v\in V_{T}\) then \(B_{v}\)=1. 10. Parameter \(S^{r}_{v}\) denotes the week in which the \(r\)-th withdrawal of product \(v\in V\) is located. 11. Parameter \(\delta^{r}_{v}\) denotes the demand in the \(r\)-th withdrawal of product \(v\in V\), for \(r=1\cdots M\). 12. Parameter \(d^{s}_{v}\) denotes the demand to withdraw in week \(s\) for product \(v\in V\). 13. Parameter \(D_{s}\) denotes the working days for each week \(s\). Two cases are considered: a five day working week (from Monday to Friday) and a five and a half working week (from Monday to Saturday noon). 14. Parameters \(P\), \(Q\), and \(R\) are weights for each of the three components considered in the cost function to optimize; they are defined as unit conversion coefficients that allow expressing the overall cost in a single unit. * Decision variables: 1. Variable \(x_{v,l}^{s,r}\in\mathds{R}^{+}\) denotes the quantity of product \(v\in V\) produced in the line \(l\in L\) in the week \(s\) for the \(r\)-th withdrawal (integer variable, measured in tons). 2. Variable \(t_{l}^{s}\in\mathds{Z}^{+}\), the number of shifts to consider in line \(l\in L\) in week \(s\) (integer variable). 3. Variable \(y_{v,l}^{s}\) denotes the production of a given product on a line (binary variable), defined by \[y_{v,l}^{s}=\left\{ \begin{array}{ll}1&\text{if and only if line $l$ is producing any quantity of product $v\in V$ in},\\ &\text{week $s$}\\ 0&\text{otherwise.}\end{array} \right.\]
4. Variable \(p_{v,l}^{s}\) denotes if a product is the first to be produced in a line (binary variable), defined by \[p_{v,l}^{s}=\left\{ \begin{array}{ll}1&\text{if and only if product $v\in V$ is the first product to be produced in}\\ &\text{week $s$ in $l\in L$},\\ 0&\text{otherwise.}\end{array} \right.\]
5. Variable \(u_{v,l}^{s}\) denotes if a product is the last to be produced in a line (binary variable), defined by \[u_{v,l}^{s}=\left\{ \begin{array}{ll}1&\text{if and only if product $v\in V$ is the last product to be produced in}\\ &\text{week $s$ in $l\in L$},\\ 0&\text{otherwise.}\end{array} \right.\]
6. Variable \(w_{v,l}^{s}\) denotes if a product ends a week and starts the next week in the same line (binary variable), defined by \[w_{v,l}^{s}=\left\{ \begin{array}{ll}1&\text{if product $v\in V$ ends the week $s$ and starts the week $s+1$ in line}\\ &l\in L,\\ 0&\text{otherwise.}\end{array} \right.\]
7. Variable \(c_{l}^{s}\) denotes if a cleaning is avoided in a line (binary variable), defined by \[c_{l}^{s}=\left\{ \begin{array}{ll}1&\text{if in the week $s$, one cleaning of the line $l\in L$ is avoided,}\\ 0&\text{otherwise.}\end{array} \right.\]  
Considering the previously defined sets, parameters, and variables, the mathematical formulation of the problem as a Mixed-Integer Linear Programming (MILP) problem is presented in Equations (1)-(16). than labor) of using one line to produce during one hour. The parameter \(R\) accounts for the variable costs per hour (other than labor) of every cleaning procedure on one line. The linear combination approach is appropriate since all considered costs are variable and vary in a directly proportional manner with respect to the decision variables, e.g., labor cost is proportional to the number of scheduled shifts; energy, supplies and amortization costs are proportional (considering different rates) to the machines operational hours and to the cleaning hours, respectively. Equations (2)-(16) formulate the constraints of the optimization problem.