ProductMixer: LP-Based Blend Optimization in Refinery Simulation

What Is LP-Based Blend Optimization?

       ProductMixer is a refinery blend optimization component in the Petroleum Refining Library that integrates linear programming directly into refinery digital twin simulation models. Instead of using predefined blend recipes, ProductMixer formulates and solves a linear programming (LP) model that automatically selects the best combination of available components. The optimization considers stream availability, product quality constraints, process limitations, and user-defined objectives such as maximizing product value, or reducing the use of expensive blend components. As operating conditions change during a simulation, ProductMixer recalculates the optimal blend, enabling realistic refinery planning, scheduling, and digital twin applications.

Operating Modes

       ProductMixer supports two operating modes that provide different levels of flexibility for blend optimization.
Automatic Mode
       In Automatic Mode, ProductMixer automatically builds the optimization model from product specifications, available input streams, and operating constraints. Quality requirements are automatically loaded from the database and converted into optimization constraints without requiring the user to define mathematical equations.
       ProductMixer can also operate in a simplified mode that calculates only additive requirements. In this case, no optimization objective or operational constraints are defined. The system automatically determines the required additive quantities needed to achieve the specified product quality.

Manual Mode
       In Manual Mode, the optimization model is defined entirely by the user. Decision variables, objective functions, and optimization constraints are specified explicitly, providing maximum flexibility for custom optimization problems.

Optimization Triggers

       ProductMixer recalculates the optimal blend whenever refinery operating conditions change. During recalculation, the simulation is temporarily paused, the current process state is transferred to the optimization engine, and the updated blend is returned before the simulation resumes.
       Optimization can be triggered in three ways:
  • Flow Changes – automatically when the flow rate of any input stream changes.
  • Seasonal Changes – automatically when seasonal product specifications or operating conditions are updated.
  • Manual Recalculation – initiated by the user to immediately rebuild and solve the optimization model using the current process state.

Why Use Mathematical Programming for Blending?

       Traditional refinery blending often relies on predefined recipes and manual engineering decisions based on operating experience. While this approach is suitable for stable operating conditions, it becomes increasingly difficult as the number of blend components, quality specifications, and process constraints grows. In many refineries, blend calculations are still performed using engineering spreadsheets such as Microsoft Excel, where engineers iteratively adjust component ratios to obtain a feasible solution. As a result, the final blend is often feasible rather than truly optimal, since evaluating all possible combinations manually is impractical. ProductMixer replaces this trial-and-error process with LP-based optimization, automatically calculating the optimal blend for the current operating conditions while satisfying all defined constraints.
Traditional blending typically produces a feasible rather than optimal solution because it is based on a static snapshot of refinery operating conditions.
       Traditional blend calculations represent only a static snapshot of refinery operation. Because process conditions continuously change, a previously calculated blend may quickly become suboptimal. ProductMixer overcomes this limitation by automatically rebuilding and solving the LP model throughout the simulation, ensuring that every optimization reflects the current refinery state.
       Refinery blending involves multiple variables that must satisfy numerous quality and operational constraints simultaneously. Changing the proportion of one component often affects several product properties, making manual calculations or fixed blending rules impractical. Mathematical Programming solves this refinery blending optimization problem by evaluating all available blend components simultaneously to produce an optimal product blend. The model determines the optimal stream proportions that satisfy every constraint while achieving the selected optimization objective, providing efficient and realistic blending decisions for refinery simulation.

How ProductMixer Integrates Optimization into Simulation?

       Unlike standalone optimization software, ProductMixer is tightly integrated with the refinery digital twin. Whenever operating conditions change—such as variations in input stream flow rates, seasonal property changes, or a manual recalculation request—the simulation temporarily pauses and transfers the current state of the process to the ProductMixer optimization engine.
       Each optimization cycle follows the same automated workflow. ProductMixer first collects the current state of all connected input streams, including instantaneous flow rates, stream properties, product specifications, and operating constraints. Based on this information, it automatically generates a new LP model by creating the required decision variables and assembling all active optimization constraints. The selected LP solver then computes the optimal blend composition and determines the accepted and rejected portions of every incoming stream. Finally, the calculated split ratios are returned to the refinery simulation, which immediately resumes execution using the optimized flow distribution. This automated workflow ensures that every optimization cycle reflects the current refinery state without requiring users to formulate or modify mathematical models.
Decision Variables
       In ProductMixer, decision variables are generated automatically from all eligible input streams connected to the component. Each connected stream becomes a variable representing its flow rate within the optimization model. During optimization, the LP solver determines the value of every variable while respecting all defined constraints. Whenever streams are added, removed, or become unavailable, the component updates the set of decision variables before rebuilding the LP model. Only streams that are available and eligible for blending are included in the optimization model.
Variable Meaning
x₁ Flow rate of Stream 1
x₂ Flow rate of Stream 2

xₙ Flow rate of Stream n
Objective Function
       The objective function defines the optimization goal used by ProductMixer when calculating the optimal blend. Two optimization objectives are supported, depending on the current operating scenario. During active shipment execution, ProductMixer maximizes product production while satisfying all quality and operational constraints. After the shipment plan has been completed, the optimization objective usually changes to minimize additive consumption (e.g., MTBE) while continuing to produce on-specification product for reservoir park replenishment.

Optimization Constraints

      The optimization model is subject to a set of linear constraints that define the feasible operating region. These constraints ensure that the calculated refinery blend satisfies product specifications, process constraints, stream availability, and downstream operating limitations. ProductMixer automatically assembles all active constraints into the LP model before each optimization run. Only solutions satisfying every constraint are considered feasible by the LP solver. Constraint generation is performed automatically from the current ProductMixer configuration, eliminating the need to manually formulate LP equations or constraint matrices.

Quality Constraints

      Quality constraints define the acceptable range for the properties of the final blend. ProductMixer ensures that every calculated solution satisfies the specified minimum and maximum limits before it is accepted. Typical quality properties include density, sulfur content, octane number, viscosity, vapor pressure, flash point, and other linear blend properties. Multiple quality constraints can be applied simultaneously, allowing the optimization model to produce blends that meet refinery product specifications. Quality limits are configured as ProductMixer properties stored in the database and are applied automatically to every optimization run.

Stream Availability Constraints

      Each input stream is limited by its available flow rate. ProductMixer ensures that the optimized blend never consumes more material than is currently available from any source. If the availability of a stream changes during the simulation, the optimization model is automatically updated. This enables ProductMixer to adapt the blend composition dynamically while maintaining a feasible solution under changing operating conditions. ProductMixer continuously monitors the availability of every connected stream and automatically excludes unavailable streams from the optimization model when necessary.

User-Defined Constraints

      ProductMixer supports custom linear constraints to represent refinery-specific operating rules that are not covered by standard blending parameters. This allows engineers to extend the standard ProductMixer optimization model without modifying the internal optimization engine. These constraints can be added to the LP model to reflect unique process requirements, business rules, or planning policies. By combining built-in and user-defined constraints, ProductMixer provides a flexible optimization framework that can be adapted to a wide range of refinery blending applications.

Blend Properties

      Blend properties define the product quality characteristics of the final refinery blend and represent the primary quality constraints used during refinery blend optimization. During each optimization cycle, ProductMixer evaluates the contribution of every input stream to ensure that the calculated blend satisfies all specified property limits. Depending on the application, blend properties may represent physical, chemical, or performance characteristics.

Supported Blend Properties

      ProductMixer can optimize any blend property that can be expressed as a linear function of the blend composition. The set of optimized properties is fully configurable, allowing users to adapt the component to refinery-specific product specifications and quality standards for gasoline, diesel, intermediate products, and other blending applications. During each optimization cycle, all selected blend properties are incorporated into the LP model simultaneously, ensuring that every accepted solution satisfies the complete set of quality specifications while achieving the selected optimization objective.

Additives

      ProductMixer supports three types of additives that can be used during blend optimization.
      Input stream Additives
      Stream additives are introduced into individual input streams before blending. They modify the properties of a specific stream and participate in the optimization process together with the remaining feed components.

      Product Additives
      Product additives are injected directly into the final blended product to achieve the required quality specifications, such as octane number, vapor pressure, or other product properties.

      Balancing Additives
      Balancing additives are available only in Automatic Mode. They are introduced automatically by ProductMixer when necessary to satisfy product quality specifications after the optimization of the primary blend. This simplifies model configuration and ensures that the final product meets all required specifications without manual adjustment.

Applicability and Limitations

      From a theoretical perspective, nonlinear optimization provides the most accurate solution for blend properties with nonlinear behavior. In practice, however, it has two major drawbacks. First, nonlinear models are computationally expensive and cannot guarantee a feasible solution within the time constraints required by dynamic simulation. Second, they are significantly more difficult to formulate, maintain, and integrate, requiring explicit mathematical equations, parameter management, and tight coupling with the simulation model.
      ProductMixer is designed for linear blend optimization. When certain blend properties exhibit nonlinear behavior, they are typically handled using one of two engineering approaches. The first approach is to introduce conservative safety margins into the linear quality constraints, ensuring that the optimized solution remains compliant under real operating conditions. The second approach is to replace automatic optimization of the affected variable with statistically validated operating limits derived from historical refinery data. For example, instead of allowing the optimizer to determine the exact contribution of a stream, its blending ratio may be restricted to a proven operating range such as 10–25%, where stable product quality has been demonstrated in practice.

Property Calculation

      For each candidate solution, ProductMixer calculates the properties of the final blend from the contributions of all input streams. Property calculations are performed automatically by ProductMixer for every candidate solution evaluated by the LP solver. Each stream contributes according to its flow rate and the corresponding property value. These calculated properties are then compared with the specified quality limits. Only blend compositions that satisfy all property constraints are considered feasible and can be selected as the optimal solution by the LP solver.

LP Mathematical Formulation

      The LP model converts the current state of the refinery simulation into a linear programming (LP) model. ProductMixer performs this conversion internally, allowing users to work with engineering parameters instead of mathematical equations. Available streams, blend properties, operational limits, and user-defined objectives are translated into decision variables and linear constraints that can be processed by a compatible optimization solver. The internal mathematical model is generated automatically for each optimization cycle and does not require users to formulate LP equations manually. This allows engineers to focus on defining engineering constraints and product specifications rather than implementing optimization algorithms.
      The complete mathematical formulation, including the objective function, matrix representation, constraint equations, and optimization methodology, is described in the article Linear Programming Model for Refinery Blend Optimization.

Refinery Blending Applications

      ProductMixer can be used for gasoline blending, diesel blending, refinery product blending, feedstock allocation, intermediate product preparation, production planning, and refinery scheduling. Typical applications include gasoline pool optimization, diesel blending, intermediate stream preparation, feedstock allocation, and refinery production planning. The component is equally suitable for digital twins, operational studies, what-if analyses, and production scheduling, enabling realistic simulation of refinery blending processes under changing operating conditions.

Integration with Petroleum Refining Library

      ProductMixer integrates seamlessly with other Petroleum Refining Library components to support complete refinery simulation workflows. It typically receives material from one or more Source components or upstream process units and supplies the optimized blend to downstream equipment such as Plant, Reservoir Park, Loading Rack, or other process units. Because ProductMixer operates within the simulation model, optimization results automatically reflect changes in material availability, process conditions, and downstream demand, enabling consistent blending decisions across the entire refinery model.

Best Practices

  • Verify Input Stream Data
    Ensure that all input streams have accurate flow rates and quality properties before optimization. Incorrect or incomplete data directly affect the quality of the calculated blend.
  • Define Realistic Property Limits
    Use property limits that accurately represent product specifications and refinery operating conditions. Unrealistic values may result in infeasible optimization problems or impractical blend compositions.
  • Use Only Necessary Constraints
    Include only the constraints required to describe the blending problem. Eliminating unnecessary restrictions improves solver performance and increases the likelihood of finding an optimal solution.
  • Select the Appropriate Optimization Objective
    Choose an objective function that reflects your engineering or business goal, such as maximizing product value, or optimizing component utilization.
  • Recalculate Blends as Conditions Change
    Allow ProductMixer to rebuild and solve the optimization model whenever stream availability, product specifications, or operating conditions change to maintain realistic simulation results.

Conclusion

      LP-based refinery blend optimization enables refinery simulation models and digital twins to produce realistic, economically optimal, and operationally feasible blending decisions under continuously changing operating conditions. By combining quality specifications, operational constraints, and optimization objectives within a single linear programming model, the blending engine determines the optimal blend composition for each simulation scenario.
      Whether used for production planning, process optimization, or refinery digital twins, ProductMixer provides a flexible and scalable framework for modeling complex blending operations. By combining refinery simulation with linear programming optimization, ProductMixer enables engineers to evaluate blend quality, operational constraints, and production objectives within a single digital twin environment, supporting better planning and more informed operational decisions.
      ProductMixer combines refinery simulation with mathematical optimization to automatically generate feasible and economically optimal blending decisions under continuously changing operating conditions, making it suitable for production planning, scheduling, and refinery digital twins.

FAQ

1. What is LP-based blend optimization?
LP-based blend optimization uses linear programming to determine the optimal proportions of multiple input streams while satisfying quality specifications, operational constraints, and optimization objectives.

2. What optimization objectives can ProductMixer solve?
ProductMixer can optimize various objectives, including maximizing product production, minimizing additive consumption, or other user-defined linear objectives.

3. Which blend properties can be optimized?
Any property that can be represented as a linear function of the blend composition can be included in the optimization model. Typical examples include density, sulfur content, octane number, viscosity, vapor pressure, and flash point.

4. Can multiple quality constraints be applied simultaneously?
Yes. ProductMixer supports multiple quality constraints within the same optimization model. Every calculated solution must satisfy all active constraints before it is considered feasible.

5. Does ProductMixer support dynamic optimization?
Yes. The component rebuilds and solves the optimization model whenever stream availability, product specifications, or operating conditions change during the simulation.

6. Which optimization solvers are supported?
ProductMixer can use the integrated lp_solve linear programming solver to compute the optimal solution for the generated LP model.

7. Is ProductMixer suitable for refinery digital twins?
Yes. ProductMixer is designed for production planning, operational studies, scheduling, what-if analysis, and digital twin applications where realistic blending decisions must be simulated under continuously changing operating conditions.

8. What happens if no feasible solution exists?
If no feasible solution is found, ProductMixer routes all incoming streams to the residual output instead of producing the target blend. This typically indicates conflicting quality constraints, unrealistic product specifications, or insufficient availability of suitable blend components.

9. Does ProductMixer support multiple products?
Yes. A refinery model may contain multiple ProductMixer components operating simultaneously, each producing a different product such as gasoline, diesel, jet fuel, or intermediate streams. Every ProductMixer builds and solves its own optimization model independently while interacting with the same simulation environment.

10. Can optimization run in real time?
Yes. ProductMixer is designed for repeated optimization during simulation and is suitable for real-time and faster-than-real-time refinery digital twins. As operating conditions change, the component rebuilds the LP model and computes a new optimal blend without requiring changes to the simulation logic.

11. How often is the LP model rebuilt?
The LP model is rebuilt whenever an optimization cycle is triggered. Depending on the simulation configuration, this may occur at fixed time intervals, after changes in stream availability, product specifications, operating conditions, or in response to user-defined events. Rebuilding the model ensures that every optimization is based on the current state of the refinery simulation.

12. Can ProductMixer optimize blend cost and quality simultaneously?
Product quality is represented by constraints, while the optimization objective minimizes cost or maximizes another user-defined objective. Therefore, the optimal solution always satisfies all quality specifications before optimizing the selected objective.