DOI: 10.3303/CET25117172 Paper Received: 15 January 2025; Revised: 23 March 2025; Accepted: 18 May 2025 Please cite this article as: de O. Lima R.A., Guirardello R., 2025, Long-term Turnaround Planning for an Oil Refinery Using a Milp Model, Chemical Engineering Transactions, 117, 1027-1032 DOI:10.3303/CET25117172 CHEMICAL ENGINEERING TRANSACTIONS VOL. 117, 2025 A publication of The Italian Association of Chemical Engineering Online at www.cetjournal.it Guest Editors: Fabrizio Bezzo, Flavio Manenti, Gabriele Pannocchia, Almerinda di Benedetto Copyright © 2025, AIDIC Servizi S.r.l. ISBN 979-12-81206-17-5; ISSN 2283-9216 Long-Term Turnaround Planning for an Oil Refinery using a MILP Model Ricardo A. de O. Lima*, Reginaldo Guirardello University of Campinas (Unicamp), School of Chemical Engineering, Av. Albert Einstein, 500, 13083-852. r992382@dac.unicamp.br This study presents a discrete-time mixed-integer linear programming (MILP) model to optimize long-term maintenance turnaround scheduling in an oil refinery focused on fuel production. Refineries are complex networks of integrated process units, and maintenance turnarounds, involving temporary shutdowns for inspection and repair, can significantly disrupt production and reduce revenues. The MILP model aims to minimize these disruptions by optimizing turnaround schedules while maintaining product supply and maximizing economic performance. The model built in GAMS incorporates flow, labor, resource, and planning constraints, allowing for different unit groupings and scenario simulations. Key outputs include the maintenance schedule, unit utilization rates, intermediate stock levels, production, manpower, and maintenance costs. The model serves as a decision-support tool for refining managers, enabling them to plan maintenance interventions that maximize operating profit while adhering to operational constraints. 1. Introduction Oil refineries rely on interconnected production units and storage systems. A turnaround is a necessary periodic shutdown of process units for maintenance to ensure equipment reliability and safety and to prevent costly breakdowns. Maintenance shutdowns are a significant factor in chemical plant availability, influencing economic performance due to their impact on operational uptime, production planning, and inventory decisions. Scheduled turnarounds involve high costs, reduced operational availability, and short product sales, making the timing and sequencing of shutdowns critical. Coordinated planning must consider production interdependencies, environmental factors, and compliance with standards to mitigate market disruptions and increase profitability. The interconnected nature of refinery units also creates opportunities to optimize resource utilization and asset availability, presenting a complex challenge in turnaround scheduling. Traditional turnaround planning in refineries typically relies on practical experience, the maintenance history of units, or follows the “we’ve always done it this way” approach. It often also involves scenario simulations and trial-and-error methods, frequently requiring the planning team to manually navigate complex decision trees often with the help of spreadsheets. As an alternative, a Mixed-Integer Linear Programming (MILP) model is proposed to optimize refinery-level maintenance planning. This approach is commonly used in oil refining but is rarely applied at the refinery level for turnaround planning. Thus, the proposed decision-support tool helps managers develop efficient schedules, maximizing profitability while meeting operational constraints, thereby enhancing broader planning efforts and improving overall refinery performance. 2. Literature review Maintenance planning in chemical engineering can be treated as an operational research (OR) problem due to the complex synergy between industrial processes and constraints. Formulations depend on whether the plants are continuous or batch, whether they are for a single process or site-wide, if the time-period is short-term or long-term and the approaches taken. To deal with production and maintenance schedules, Sanmartí et al. (1997) integrated reliability indexes into production planning for batch plants, minimizing delays from equipment failures and optimizing plans for robustness. For continuous processes, Jain and Grossmann (1998) addressed maintenance planning using a Mixed-Integer Nonlinear Programming (MINLP) model to optimize shutdown 1027 intervals based on performance decay, costs, and production losses, with applications like ethylene production. Cheung et al. (2004) formulated a multi-period Mixed-Integer Linear Programming (MILP) model for short-term maintenance planning, balancing material and utility costs to maximize profit of a chemical production site. Similarly, Amaran et al. (2015) developed MILP models for long-term multi-plant site maintenance planning, optimizing net present value (NPV), financial performance, and labor balance. Peng and Ricardez-Sandoval (2021) explored the benefits of flexible preventive maintenance schedules, demonstrating profit improvements in continuous processes like non-isothermal reactors. More specific approaches include Megow et al. (2011), who developed algorithms for turnaround activities, focusing on cost and task scheduling, and Laggoune et al. (2009), who optimized maintenance for multi-component equipment, grouping replacements using Monte Carlo simulations. Finally, Wu et al. (2015) proposed a Degradation-Based Maintenance (DBM) model, optimizing maintenance intervals and actions based on degradation levels and cost-effectiveness, applicable to systems with measurable wear factors. These studies collectively emphasize robust, adaptable maintenance strategies to enhance operational efficiency and to reduce costs. 3. Problem description This work presents a long-term maintenance turnaround planning framework for refineries, emphasizing process unit utilization, production, and buffer stock management while disregarding short-term effects. A simplified network model captures industry-specific constraints, including seasonal factors, labor peaks, product demand, and storage limitations. Utilizing a Mixed-Integer Linear Programming (MILP) model with monthly time discretization, the approach schedules maintenance shutdowns and evaluates secondary metrics such as unit utilization, oil consumption, intermediate inventories, maintenance costs, and refining margins. The model, though abstract, can be adapted to specific refinery characteristics for more precise insights. It includes units for crude oil distillation (DST1, DST2), delayed coking (CKU1, CKU2), catalytic cracking (FCC), hydrotreatment (HDT1, HDT2, HNK), and catalytic reforming (URC), along with intermediate storage tanks, mixers, and flow splitters. Input (crude oil) and output (oil products) tanks ensure sufficient inventory capacity, though raw material and product inventories were not explicitly modeled. Auxiliary units are not directly represented but are assumed to undergo maintenance alongside the main units they support. Their maintenance costs are integrated into the overall expenses of the primary units, ensuring a comprehensive maintenance strategy. This work excludes tank maintenance planning, focusing instead on process unit turnarounds, which require significant additional labor and infrastructure adjustments. The study focuses on five key oil products—LPG, gasoline, diesel, fuel oil, and coke—due to their significant production volumes and economic impact. These products drive maintenance planning as they represent the largest revenue fractions and play a critical role in the local economy. Historical data informs restrictions on labor capacity during maintenance and maintenance complexity, ensuring compliance with the refinery's maximum accommodation limits and resources. Maintenance productivity in refineries is highly influenced by weather, with conditions like rain or extreme heat increasing downtimes and costs. The proposed model incorporates climatic factors, scheduling maintenance during favorable weather months and using historical data to adjust costs and durations with a "lost profit factor" for reduced productivity. It also adheres to Brazilian regulations (NR-13), enforcing a maximum interval of six years between inspections and a minimum of 18–24 months between major turnarounds, ensuring sufficient preparation time for planning and budgeting. The model uses a monthly time base to balance strategic price projections, typical shutdown durations, and computational efficiency. Long-term price forecasts are refined monthly, avoiding unnecessary complexity. By integrating regulatory, operational, and climatic considerations, the model provides a reliable and practical framework for long-term maintenance planning in refineries. Objective function The objective function that represents the total profit during the whole planning horizon is shown in Eq(1). max ∑ (∑ ∑ p s,t xi,OT,s,t ds⁄ - s∈Pdi∈I ∑ ∑ p s,t xIT,j,s,t ds⁄ - s∈Rwj∈I ∑ p s,t sttq(s),t ds⁄ - s∈Ip ∑ y i,t Cu,t i∈U ) t∈T (1) The variables of the Eq(1) are: (1) product quantities to the final tanks represented by xi,OT,s,t; (2) the oil quantities from the distillation feed tanks represented by xIT,j,s,t; (3) the intermediate stocks of streams, sttq(s),t and (4) the binary variable y i,t which indicates the start of unit ‘u’ maintenance in period ‘t’. The other factors of the equation are parameters. The prices of raw materials, intermediate products, and finished products are represented by p s,t . Maintenance costs, Cu,t, vary by unit since plants differ in the number of equipment and complexity, requiring specific services and differing numbers of workers. Both product prices and maintenance costs change over time. The subscripts 1028 “IT” and “OT” represent the tanks for raw materials (specifically, petroleum) and finished products, respectively. The maintenance cost per unit for each period is multiplied by the binary variable y i,t that indicates the start of maintenance of unit “u”, in period “t”. This variable assumes a value of 0 (zero) when the unit is operating and a value of 1 when the unit enters maintenance. In mathematical notation, the constraint is expressed by Eq(2): y i,t ∈{0,1} (2) Network flow constraints The constraints of the model related to flows between the network nodes are described by Eq(3) to Eq(12). ∑ xi,j,s,t= s∈S ∑ xj,k,s,t s∈S (3) ∑ xi,j,s,t+1+sttq(s), t= s∈S ∑ xj,k,s,t+1+sttq(s), t+1 s∈S (4) xj,k,s,t=Yj,s∙xi,j,r,t (5) xi,j,s,t≤Fi,j,s (1-y j,t ) (6) xi,j,s,t≥Tdi,j,s (1-y j,t ) (7) xi,j,s,t+1≤Fi,j,s [1-y j,t+1 -y j,t Flct] (8) xi,j,s,t+1≥Tdi,j,s [1-y j,t+1 -y j,t Flct] (9) stvoltq(s),t≥ stvoltq(s) min (10) stvoltq(s,)t≤ stvoltq(s) max (11) stvoltq(s),1= stvoltq(s) ini (12) Maintenance constraints The constraints presented in this section are related to maintenance planning. The constraints are represented by Eq(13) to Eq(18). ∑ (1-y i, t+n ) Nu max n=0 ≤ Nu max (13) ∑ (y i, t+n ) Nu min n=0 ≤ 1 (14) y i,t + ∑ y i ' ,t+n 24 n=0 ≤ 1 i= ‘DST1’ and ‘DST2’; i ' = ‘DST1’ and ‘DST2’; i≠i ' (15) ∑ y i, t Lu t=1 ≥ 1 (16) ∑ y i,t mui∈U ≤ mmax (17) ∑ y i,t Fcui∈U ≤ Fc max (18) Demand constraints The study defines the refinery's obligation to meet minimum demand levels by Eq(19). ∑ ∑ xi,OT,s,t ≥ Ds,t s∈PdiϵI (19) 1029 The MILP model The model was built in GAMS 23.2.1 and was solved using the CPLEX 12.1.0 solver. 4. Case study The refining scheme in the form of a network studied in this work is presented in Figure 1. Although the model does not exactly correspond to a specific refinery, this work is based on historical maintenance data from a refinery located in Brazil. Based on the previous maintenance history presented in Table 1, three groups of shutdowns were automatically configured: two large groups that include crude distillation units and one group called 'independent,' composed of the Coker Naphtha Hydrotreatment Unit (HNK) and the Catalytic Reforming Unit (URC). The groups for turnarounds are presented in Table 1. Figure 1: Schematic of the oil refinery in the form of a network (case study). Table 1: Maximum time until the first turnaround and group for turnarounds (groups 1, 2 and I). Unit Maximum time until the first turnaround, Lu, months Group for turnarounds Unit Maximum time until the first turnaround, Lu, months Group for turnarounds Unit Maximum time until the first turnaround, Lu, months Group for turnarounds DST1 62 1 FCC 50 1 DST2 17 2 CKU1 62 1 HNK 34 I CKU2 17 2 HDT2 62 1 URC 34 I HDT1 17 2 This study analyzed six scenarios to optimize refinery maintenance planning by varying the intervals between major shutdowns and the campaign times of the Catalytic Cracking Unit (FCC). The scenarios are summarized in Table 2. Table 2: Study scenarios. Maximum number of periods between FCC turnarounds, months Minimum number of periods between large shutdowns, months 60 72 48 24 1 2 3 18 4 5 6 Scenarios 1–3 used a 24-month minimum interval, exploring FCC maximum cycle lenght of 60, 72, and 48 months (only the first turnaround). Scenarios 4–6 reduced the interval between major turnarounds to 18 months, with similar FCC campaign variations to evaluate the impact of enhanced maintenance planning resources. 1030 5. Results and analysis The results of the six scenarios are evaluated, focusing on key economic indicators and identifying the factors influencing the outcomes. This analysis will help to understand the overall performance and efficiency of each scenario in the context of refinery maintenance and production. The turnaround schedules are presented in Table 3. Optimal scheduling indicates that general shutdowns should occur preferably in August to minimize maintenance time and revenue loss, as the price differences in other periods do not offset production losses. The main aggregated results are presented in Table 4. Table 3: Turnaround schedule. Turnaround 1 2 3 4 5 6 7 8 Scenarios 1 and 4 Group 2+I 1 2+I 1 2+I 1 - - Time (month) 8 44 80 104 140 164 - - Month/Year Aug/24 Year 1 Aug/27 Year 4 Aug/30 Year 7 Aug/32 Year 9 Aug/35 Year 12 Aug/37 Year 14 - - Scenarios 2 and 5 Group 2+I 1 2+I 1 2+I - - - Time (month) 8 56 80 116 140 - - - Month/Year Aug/24 Year 1 Aug/28 Year 5 Aug/30 Year 7 Aug/32 Year 9 Aug/35 Year 12 - - - Scenarios 3 and 6 Group 2+I 1 2+I 1 2+I 1 - - Time (month) 8 32 68 92 128 152 - Month/Year Aug/24 Year 1 Aug/26 Year 3 Aug/29 Year 6 Aug/31 Year 8 Aug/34 Year 11 Aug/36 Year 13 - - Table 4: Main aggregated results – 15-year horizon. Scenarios 1 & 4 2 & 5 3 & 6 Average Refining Level 97.1% 97.7% 97.1% Production (10³ m³) LPG 8,325 8,379 8,325 Gasoline 27,933 28,115 27,933 Diesel 84,393 84,939 84,393 Fuel Oil 3,930 3,978 3,930 Coke 9,451 9,512 9,451 Maintenance Cost Index 5.90 4.88 5.98 Days in Maintenance 222 185 222 Maintenance Cost/Revenue 0,58% 0,48% 0,59% Revenue/Maximum Revenue 99,41% 100,00% 99,38% Normalized Profit 1,0000 1,0177 0,9993 Delta Refining Margin (US$/bbl) - 0,10 -0,13 The optimal strategy consolidates shutdowns of HNK and URC units with Group 2 units, reducing unit groups to two and advancing their first turnaround by 26 months. Over a 15-year horizon, Scenario 2, with a 72-month FCC campaign, achieves the best economic results by requiring only 5 turnarounds compared to 6 in Scenarios 1 and 3. This reduces total downtime to 185 days, a 16.7% improvement over the other scenarios. In Scenarios 4, 5, and 6, reducing the minimum interval between major shutdowns from 24 to 18 months expanded the solution domain but yielded identical results in schedule, mass balance, and economic outcomes as Scenarios 1, 2, and 3. This indicates that, within the given model's input data, parameters, and constraints, a shorter interval between major turnarounds did not improve scheduling or economic performance. Scenarios 1 and 4 represent the optimal schedule under usual constraints, achieving a refining level of 97.2%, 99.41% of the maximum revenue, and maintenance costs of 0.58% of revenue. Scenarios 2 and 5 deliver the best outcomes by extending the FCC campaign to 72 months, resulting in the highest refining level, revenue, and profit margin, and a US$ 0.10 per barrel increase in gross refining margin. This extension also reduces the number of turnarounds, alleviates pressure on other refineries, and boosts gasoline and diesel output. In 1031 contrast, Scenarios 3 and 6, which reduce the FCC first cycle lenght to 48 months, incur higher maintenance costs and lower revenue, leading to a profit margin 0.07% lower than Scenario 1. 6. Conclusions This study introduces a methodology and mathematical model for optimizing maintenance schedules in petroleum refineries focused on fuel production, addressing the financial impact of maintenance in integrated industrial complexes. Using a Mixed Integer Linear Programming (MILP) model with discrete time over a 15- year horizon, the study generates and analyzes schedules across various scenarios, evaluating them with economic indicators such as profit, revenue, maintenance costs, utilization factors, downtime, and production volumes. The model also addresses practical concerns like grouping strategies, providing a decision-support tool for refinery managers to optimize economic outcomes while considering real-world constraints. Furthermore, the model can inform broader company-wide maintenance strategies for multiple refineries. Future research could refine the model by incorporating varying maintenance durations, additional products like aviation fuel, and expanded network models to include more units and account for energy and utility costs. Nomenclature Cu,t – maintenance cost of unit ‘u’ in period ‘t’, 10³ US$ Ds,t – demand of product s in period t, 10³ t ds – stream density, t/m³ Fc max – maximum maintenance complexity factor Fcu – maintenance complexity factor of unit ‘u’, - Fi, j, s – maximum product quantity from node ‘i’ to ‘j’ of product ‘s’, t/month Flct – lost profit factor in the period t, - Lu – maximum time until the first maintenance shutdown of unit u, months mmax – maximum labor supported at the refinery (manpeak), - mu – labor for the maintenance of the unit u (manpeak), - Nu max – maximum time periods between turnarounds for unit ‘u’, months Nu min – minimum time periods between turnarounds for unit ‘u’, months p s,t – price of raw materials and products ‘s’ in the period t, US$/m³ stq(s) min – minimum stock of product ‘s’ in the tank ‘tq’, 10³ t sttq(s) max – maximum stock of product ‘s’ in the tank ‘tq’, 10³ t sttq(s),t – inventory of the intermediate product ‘s’ in the tank ‘tq’ the period ‘t’, 10³ t sttq(s) ini – initial stock of product ‘s’ in tank ‘tq’, 10³ t stvoltq(s) max – maximum volumetric stock of product ‘s’ in the tank ‘tq’, 10³ m³ stvoltq(s) ini – initial volumetric stock of product ‘s’ in tank ‘tq’, 10³ m³ stvoltq(s) min – minimum volumetric stock of product ‘s’ in the tank ‘tq’, 10³ m³ Tdi,j,s – minimum product quantity from node ‘i’ to ‘j’ of product ‘s’ (turndown), t/month xi, j, s, t – mass from node ‘i’ to ‘j’ of stream ‘s’ in the period t, 10³ t Yu, s – vector of yields of stream ‘s’ in unit ‘u’, t/t y u,t – binary representing the start of maintenance for unit ‘u’ at time ‘t’, - References Amaran, S., Sahinidis, N., Sharda, B., Morisson, M., Bury, S., Miller S., Wassick, J., 2015. Long-term turnaround planning for integrated chemical sites, Comput. Chem. Eng.; 72,145-158. Cheung K-Y, Hui C-W, Sakamoto H., Hirata K., O’Young L., 2004. Short-term site-wide maintenance scheduling. Comput. Chem. Eng.; 28,91–102. Jain V, Grossmann I.E., 1998. Cyclic scheduling of continuous parallel-process units with decaying performance. AIChE J.; 44,1623–36. Laggoune R, Chateauneuf A, Aissani D., 2009. Opportunistic policy for optimal preventive maintenance of a multi-component system in continuous operating units. Comput. Chem. Eng. 33,1499–510. Megow N., Möhring R.H., Schulz J., 2011. Decision support and optimization in turnaround and turnaround scheduling. INFORMS J. Comput.; 23,189–204. Peng, Y., Ricardez-Sandoval, L., 2021. Integration of planning, scheduling, and control for multi-product chemical systems under preventive maintenance, IFAC-PapersOnLine; 54-3, 536-541. Sanmartí E., Espuña A., Puigjaner L., 1997. Batch production and preventive maintenance scheduling under equipment failure uncertainty. Comput. Chem. Eng., 21, 1157–68. Wu, F., Niknam, S. A., Kobza, J. E., 2015. A cost effective degradation-based maintenance strategy under imperfect repair, Reliab. Eng. Syst. Saf.; 144, 234-243. 1032 CET-vol117-b.pdf 39lima.pdf Long-Term Turnaround Planning for an Oil Refinery using a MILP Model