# Production Optimization in a Grain Facility through Mixed-Integer Linear Programming +
## 3 The Grain Facility Optimization Problem
The constraint in Equation (2) states that production must be greater than demand, guaranteeing that there is sufficient production of inoculated products to be delivered. Since inoculated products have an expiration date, the model must ensure that the number of weeks elapsed since inoculated products are produced until they are delivered does not exceed the shelf life for expiring products, given by parameter \(\tau\). The constraint in Equation (3) guarantees that enough treated products are produced to satisfy the demand. In the same way as for constraint in Equation (2), the production must be greater than the demand, but in this case the products can be produced at any moment of the production cycle, since shelf life is not a constraint for treated products. The constraint in Equation (4) controls the storage capacity. The first term on the left side of the inequality corresponds to the overall production of week \(s\) and the second term corresponds to the deliveries scheduled for that week. The difference between production and delivery must be positive and cannot exceed the total storage capacity, given by parameter \(C\), to guarantee that the surplus of production can be stored. The constraint in Equation (5) specifies a limit for the number of shifts to be performed for each production line in each week. The group of constraints in Equations (6)-(11) controls the activation of binary variables \(y^{s}_{v,l}\)\(y^{s}_{v,l}\), \(u^{s}_{v,l}\) y \(w^{s}_{v,l}\). These variables are used as auxiliary variables for the calculation of the number of cleanings avoided in the production lines. The constraints in Equations (6) and (7) operate together to activate the variable \(y^{s}_{v,l}\) if and only if some quantity of a certain product \(v\) is produced on the line \(l\) in the week \(s\). The constraint in Equation (8) states that the necessary condition for the variable \(y^{s}_{v,l}\) to be activated (meaning that \(v\) is the first product to be produced on line \(l\) in week \(v\)) is that some quantity of product \(v\) has been produced in the week \(s\). The constraint in Equation (9) assures that the first product produced in week \(s\) on line \(l\) is unique, thus guaranteeing a consistent definition for variable \(p^{s}_{v,l}\). Inequalities in Equations (10) and (11) are analogous to the constraints in Equations (8) and (9), but in this case are applied to the last product produced in the week. To assure the existence of a last product \(v\) to be produced on the line \(l\) in week \(s\), there must be a production of said product \(v\). Furthermore, Equation (9) guarantees that the existing last product is unique. The constraint in Equation (12) forces the variable \(w^{s}_{v,l}\) to take the value \(1\) only if the production of product \(v\) is split on two weeks, i.e., product \(v\) is the last product of week \(s\) and the first of the week \(s+1\) for the production line \(l\). The inequality in Equation (13) controls the cleaning variable \(c^{s}_{l}\), which indicates whether a cleaning is saved on production line \(l\) for week \(s\). The sum of variables \(c^{s}_{l}\) appears in the objective function with a negative sign, therefore, the optimization model presses for this quantity to have the maximum possible value. The set of constraints in Equation (14) guarantees that if a certain product \(v\) is the first and the last produced on week \(s\) for a production line \(l\), no other product \(v_{1}\
eq v\) is produced on line \(l\) in the same week. The set of constraints in Equation (15) indicates that the maximum production capacity of line \(l\) must be greater than the quantity produced in that line for every week. Two terms are subtracted from the productivity of the production line \(l\): the stop times needed and the cleanings saved, according to a correct sequencing of the products to be produced.