Hybrid Simulation and Optimization for Petroleum Refinery Digital Twins

       Modern petroleum refineries operate under continuously changing conditions. Feedstock composition, production plans, equipment availability, product demand, and storage levels evolve over time, requiring engineers to make operational decisions while ssatisfying production targets while respecting process and equipment constraints, These decisions have been supported by refinery operations scheduling optimization models, most commonly based on linear programming (LP). Commercial refinery planning systems such as Aspen PIMS have long supported refinery planning, process economics, and operational decision-making.. Optimization efficiently determines feedstock allocation, blending ratios, and production plans while maximizing refinery performance under mathematical constraints. However, to remain computationally efficient, optimization models inevitably simplify refinery behavior by assuming steady-state operation, linear relationships, and limited process dynamics.
       As a result, an optimized solution is not always operationally feasible. It may overlook storage limitations, transition periods, equipment interactions, or dynamic material flows that determine how a refinery actually operates. Furthermore, optimization naturally drives refinery operation toward constraint boundaries, where equipment capacities, storage limits, or product quality specifications are fully utilized. While such solutions are mathematically optimal, they often leave little operational margin, making them highly sensitive to disturbances, uncertain feedstock properties, equipment availability, and other real-world factors that continuously affect refinery operation.
       This is why modern refinery digital twins combine simulation and optimization rather than treating them as competing approaches. Learn how refinery digital twins are built using the Petroleum Refining Library. Optimization generates the best operating plan, while continuous simulation verifies whether that plan remains feasible under real operating conditions. Together they provide a powerful decision-support system for production planning, scenario analysis, and refinery optimization.
       In this article, we explain how hybrid simulation and optimization work together in refinery digital twins and why combining both approaches produces more reliable engineering decisions than either method alone.

Why Optimization Alone Is Not Enough?

       Optimization has long been one of the primary tools for refinery operations planning because it efficiently solves complex engineering problems involving thousands of variables and constraints. Linear programming is widely used for feedstock allocation, production planning, and blending while maximizing refinery performance under process constraints and operational constraints.
However, every optimization model is an abstraction of a real refinery. To remain computationally efficient, nonlinear process behavior is linearized, dynamic effects are simplified, and many operational details are omitted. In reality, refinery operations are inherently dynamic. Material continuously flows through interconnected process units, pipelines, tank farms, and loading facilities, while equipment availability, operating modes, storage levels, and product quality requirements change over time. See how continuous material flow is modeled inside refinery tank farms. More importantly, optimization cannot be performed independently of the refinery's material flow and process network. The physical configuration of pipelines, process units, and storage facilities defines the feasible operating region available to the optimizer. Flow distribution constrains optimization—not vice versa. Product selection and production planning must therefore be optimized within the physical limits of the refinery rather than assuming that material flows can always be rearranged to satisfy an optimal solution.
       Since storage systems define the feasible operating region, tank farm design becomes one of the most important elements of refinery simulation. Furthermore, optimization naturally drives the solution toward active engineering constraints, such as equipment capacities, storage limits, or product quality specifications. While mathematically optimal, these solutions often leave little operational flexibility and may become infeasible when real operating conditions deviate from the assumptions used during optimization.
For this reason, optimization should be viewed as one component of a broader engineering workflow rather than a complete solution. It identifies the best operating strategy within a simplified mathematical model, while a refinery digital twin verifies that this strategy remains feasible under realistic operating conditions. Together, optimization and simulation provide a far more reliable foundation for production planning, operational planning, and refinery decision-making than either approach can achieve independently.

How Simulation Complements Optimization?

       Simulation extends optimization by reproducing how refinery operations evolve over time under realistic operating conditions. While optimization identifies the best operating decisions, simulation evaluates whether those decisions remain physically achievable as material continuously moves through the production network.
A refinery digital twin models the dynamic behavior of process units, pipelines, tank farms, loading facilities, and transportation systems while continuously maintaining material balance. It captures operational effects that are difficult or impractical to represent in optimization models alone, including changing flow rates, equipment operating modes, maintenance activities, storage constraints, and production schedules.
       As the simulation progresses, it reveals bottlenecks, storage limitations, and equipment interactions that may prevent an optimized production plan from being fully implemented. Engineers can evaluate alternative operating scenarios, modify process parameters, and validate production plans before changes are introduced into the real refinery.
More importantly, production planning is only one of many engineering tasks involved in refinery management. A refinery digital twin also supports the evaluation of process modifications, identification of capacity bottlenecks, balancing of material flows, maintenance planning, coordination of multiple interconnected facilities, shipment forecasting, and assessment of modernization or expansion projects. These problems require reproducing the dynamic behavior of the refinery over time rather than solving a single optimization problem.
       By combining optimization with continuous simulation, refinery digital twins become comprehensive decision-support systems rather than simply production planning tools. Optimization provides mathematically optimal operating decisions, while simulation verifies their feasibility and enables engineers to analyze a much broader range of operational and strategic scenarios. Together, they significantly improve production planning, reduce operational risk, and support more informed engineering decisions throughout the refinery lifecycle.
       One implementation of this hybrid approach is provided by the Petroleum Refining Library (PRL), where optimization is tightly integrated with continuous simulation.

Optimization Framework in Petroleum Refining Library

       Petroleum Refining Library (PRL) includes a dedicated Optimizer component that provides a unified framework for defining and solving linear programming problems directly within refinery simulation models. Rather than being limited to built-in optimization tasks, the component allows developers to formulate and solve custom linear programming models for their own engineering applications.
       The Optimizer is built on the LPsolve solver, selected for its mature Java integration, computational efficiency, and graphical debugging capabilities that simplify the analysis and verification of optimization models during development.
To simplify model implementation, the component is integrated with the Java ILP interface, which provides a high-level API for constructing objective functions and constraints without manually generating LP model definitions. This significantly reduces the amount of code required to formulate optimization problems while improving readability and maintainability.
The same Optimizer component is internally used by several Petroleum Refining Library objects, including Process Units and Blending Nodes, where it automatically solves embedded optimization problems as simulation conditions change. At the same time, it remains fully accessible to users and can be invoked directly from AnyLogic models to solve custom optimization problems that are unrelated to the built-in refinery components.
       By providing a common optimization framework for both internal library components and user-defined models, Petroleum Refining Library enables engineers to combine continuous simulation with customized linear programming within a single refinery digital twin.

How Optimization Is Embedded in a Refinery Digital Twin

       In a refinery digital twin, optimization is not performed only once during production planning. Instead, it is embedded into the simulation model and automatically invoked whenever an engineering decision cannot be determined by simulation alone.
Unlike continuous flow, which is reproduced directly by the simulation, certain refinery operations require solving mathematical optimization problems. Rather than approximating these decisions with heuristic rules, the digital twin delegates them to specialized linear programming models. Each optimization model is designed to solve a specific engineering task and returns the control parameters required for the simulation to continue.
       During execution, the simulation continuously monitors operating conditions. Whenever a change affects one of these optimization problems—such as a variation in feedstock flow rate, equipment availability, operating mode, or product quality requirements—the simulation temporarily pauses and transfers the current process state to the corresponding optimization model. After the optimal solution is found, the calculated control parameters are immediately applied to the simulation, which then resumes from the updated state.
       This event-driven interaction combines the strengths of both approaches. Simulation remains responsible for reproducing the dynamic behavior of the refinery, while optimization is executed only where mathematically optimal decisions are required. As a result, the digital twin preserves realistic process dynamics without sacrificing the computational efficiency of linear programming.

Engineering Problems Solved by Linear Programming in Refinery Digital Twins

       Not every engineering decision in a refinery requires mathematical optimization. Most refinery operations—including oil and gas flows transport, storage, equipment operation, and production scheduling - are reproduced directly by the simulation model. Optimization is invoked only for decisions where multiple feasible alternatives exist and an optimal solution must be selected while satisfying numerous engineering constraints.
       Rather than relying on a single optimization model, a refinery digital twin incorporates several specialized linear programming models, each designed to solve a specific engineering problem. This modular approach keeps individual optimization tasks computationally efficient while allowing the simulation to reproduce the overall dynamics of refinery operation.

       In Petroleum Refining Library, optimization is currently applied to three key engineering tasks:
       - feedstock allocation among parallel primary process units,
       - flow distribution between parallel processing Plant lines,
       and product-flow blending.
       Although these problems differ in objectives and constraints, they all follow the same workflow. The simulation supplies the current operating conditions, the optimization model calculates the optimal control parameters, and the simulation immediately continues using the updated solution.

       Feedstock Allocation. The first optimization problem occurs at the refinery inlet, where multiple feedstock streams originating from different crude assays must be distributed among parallel primary process units. The objective is to maximize refinery throughput while processing all available feedstock while respecting the operating limits of each unit. The optimization model receives the current flow rates from the simulation together with unit capacity constraints and calculates the optimal allocation of incoming streams.
       Process Unit Line Assignment. The second optimization problem arises inside process units containing multiple parallel processing lines. Incoming oil and gas flows must be distributed between available lines while satisfying several engineering objectives with different priorities. The primary objective is to process the entire incoming flow. Subject to this requirement, the optimization minimizes the number of active processing lines to reduce operating costs and, whenever possible, minimizes operating mode transitions, since each mode change represents a complex technological procedure that may temporarily reduce production efficiency.
       Product Blending. The third optimization problem concerns the production of finished petroleum products. Multiple intermediate streams must be blended to satisfy product quality specifications while maximizing product output and supporting yield optimization for high-value petroleum products. Depending on the product, the optimization simultaneously considers quality constraints such as octane number, Reid vapor pressure, aromatic content, and other specification limits. The resulting solution determines which portions of each incoming stream participate in the blend and which remain available for subsequent processing or storage.

Why Linear Programming Remains the Industry Standard?

       Although refinery operations involve many nonlinear processes, linear programming remains one of the most widely used optimization techniques in refinery planning and petroleum refining. Its continued adoption across the refining industry stems from from its ability to solve large engineering problems including process economics, production planning, and blending optimization.
       Many refinery optimization problems can be formulated as linear decision models by introducing appropriate engineering assumptions and linear approximations. This approach allows complex operational decisions to be solved in seconds, making linear programming well suited for integration into continuously running simulation models.
       In Petroleum Refining Library, all embedded optimization models are formulated as linear programming problems. Rather than attempting to represent every physical phenomenon directly within the optimization model, nonlinear process behavior is handled by the simulation itself, while optimization focuses exclusively on the engineering decisions that require selecting the best solution among multiple feasible alternatives.
       This separation of responsibilities provides an important architectural advantage. Continuous simulation reproduces the physical behavior of refinery operations, whereas linear programming solves localized decision-making problems quickly enough to support real-time execution of the digital twin.

Benefits of Hybrid Simulation and Optimization

       By integrating simulation and optimization into a single execution framework, refinery digital twins provide capabilities that neither approach can achieve independently. Optimization identifies the best engineering decisions under mathematical constraints, while simulation verifies their feasibility under realistic operating conditions. Together, they enable engineers to evaluate both the quality and the practicality of production planning and refinery scheduling before implementation. Storage systems play a central role in validating optimized refinery schedules.
       This hybrid approach improves decision-making across multiple refinery operations. Production plans and refinery schedules can be validated before execution, bottlenecks can be identified before they affect throughput, and alternative operating scenarios can be evaluated without disrupting the real production process. Because the simulation continuously maintains material balance while accounting for equipment constraints, storage dynamics, and logistics, engineers gain significantly greater confidence that optimized plans can be successfully implemented.
       Another important advantage is computational efficiency. Instead of repeatedly optimizing the entire refinery, the digital twin invokes optimization only for local engineering problems when changing operating conditions require new decisions. This architecture combines the speed of linear programming with the realism of continuous simulation, allowing the model to remain both responsive and computationally efficient.
       As a result, hybrid simulation and optimization provide a practical foundation for refinery production planning, operational optimization, and engineering decision support, making them a key component of modern refinery digital twins.

Conclusion

       Simulation and optimization are complementary technologies that solve different engineering problems within a refinery digital twin. Optimization identifies the best operating decisions under mathematical constraints, while simulation evaluates how those decisions perform under realistic operating conditions. Neither approach alone can accurately represent the complexity of modern refinery operations. As discussed throughout this article, flow distribution constrains optimization, not vice versa.
       By integrating both methods into a single execution framework, refinery digital twins combine mathematical optimization with continuous material flow simulation, enabling engineers to validate production planning and refinery scheduling, optimize refinery performance, evaluate operational scenarios, and support day-to-day decision-making with greater confidence.
       In Petroleum Refining Library, optimization is embedded directly into the simulation model and automatically invoked only for engineering problems that require mathematically optimal decisions. This architecture preserves the computational efficiency of linear programming while maintaining the physical realism of continuous simulation, providing a practical foundation for building accurate and scalable refinery digital twins.
       As refinery operations continue to grow in complexity, hybrid simulation and optimization will play an increasingly important role in production planning, operational optimization, and digital transformation across the downstream oil and gas industry.

FAQ

What is hybrid simulation and optimization in a refinery digital twin?
Hybrid simulation and optimization combines continuous process simulation with mathematical optimization in a single refinery digital twin. Simulation reproduces material flows, equipment behavior, and storage dynamics over time, while optimization determines the best operating decisions under engineering constraints. Together, they provide more reliable production planning and operational decision support than either approach alone.

Why is simulation needed if optimization already finds the best solution?
Optimization solves a simplified mathematical model and assumes predefined constraints. It cannot fully represent dynamic material flows, equipment interactions, storage limitations, or operating transitions. Simulation verifies whether an optimized solution remains physically feasible under realistic operating conditions.

Why is linear programming widely used in petroleum refining?
Linear programming provides an efficient method for solving large refinery planning and scheduling problems involving thousands of variables and constraints. It is widely applied to feedstock allocation, blending optimization, production planning, and process scheduling because it produces high-quality solutions within practical computation times.

Can a refinery digital twin operate without optimization?
Yes. A refinery digital twin can accurately simulate refinery operations using continuous material flow simulation alone. However, optimization significantly improves decision-making whenever multiple feasible operating alternatives exist, such as feedstock allocation, blending, or flow distribution between parallel process units.

What engineering problems are typically solved using optimization?
Typical refinery optimization problems include:
  • Feedstock allocation between parallel process units
  • Flow distribution between parallel processing lines
  • Product blending and quality optimization
  • Production planning and scheduling
  • Capacity utilization and bottleneck reduction

How does Petroleum Refining Library integrate optimization?
Petroleum Refining Library (PRL) embeds optimization directly into the simulation model. Whenever operating conditions require an engineering decision that cannot be determined by simulation alone, the Optimizer automatically solves the corresponding linear programming problem and immediately applies the calculated control parameters to the running digital twin.

Is hybrid simulation suitable only for petroleum refineries?
No. Although this article focuses on petroleum refining, the same hybrid approach can also be applied to gas processing plants, petrochemical facilities, chemical manufacturing, storage terminals, pipeline networks, and other continuous-process industries where material flows and operational constraints must be analyzed together.

Related Articles