ProductMixer Automatic Optimization Algorithms

ProductMixer Optimization Workflow

       ProductMixer performs automatic refinery blending by generating and solving a linear programming (LP) optimization model. Unlike manual blending, users define only the desired product specifications, available blend components, and operating constraints. ProductMixer automatically builds the mathematical model, executes optimization, and distributes each incoming stream between the finished product and residual streams.

The optimization workflow consists of the following stages:
  1. Loading product specifications from the product quality database.
  2. Detecting available incoming streams connected to the ProductMixer.
  3. Loading component properties for every blend component.
  4. Generating the LP optimization model, including variables, material balances, quality equations, and operational constraints.
  5. Selecting the optimization objective, such as maximizing product production or minimizing balancing additive consumption.
  6. Solving the LP problem using the configured linear programming solver.
  7. Calculating the balancing additive, if required, after a feasible blend has been found.
  8. Distributing material flows, where accepted portions are routed to the product and rejected portions are sent to residual streams.
  9. Monitoring process changes and automatically rebuilding the optimization model whenever operating conditions change.
This workflow is fully automatic and does not require users to formulate LP equations manually. All optimization variables, constraints, and objective functions are generated internally from the ProductMixer configuration and connected process streams.

Automatic LP Model Generation

       ProductMixer automatically generates a complete linear programming (LP) model for each optimization cycle. Users define only the product specifications, available blend components, and operating constraints, while all variables, equations, and the objective function are created automatically.
During model generation, ProductMixer:
  1. Detects connected incoming streams.
  2. Loads product specifications and component properties.
  3. Creates LP variables and material balance equations.
  4. Generates quality and operational constraints.
  5. Builds the objective function for the selected optimization mode.
Because the model is generated dynamically, ProductMixer automatically adapts to changes in connected streams, product specifications, and operating constraints without requiring manual modification of the mathematical model.

Product Specification Processing

       Before building the optimization model, ProductMixer loads the product specification from the configuration database. Each specification defines a quality property, its limit, comparison direction, calculation basis (mass or volume), and an optional seasonal group.
Only enabled specifications are included in the LP model. Each specification is automatically converted into one or more linear constraints that limit the properties of the final blended product.
This approach allows product specifications to be modified without changing the optimization algorithm. Adding, removing, or updating quality limits only requires updating the database configuration.

Incoming Stream Detection

       ProductMixer automatically detects all incoming streams connected to the node and includes them in the optimization model. No manual configuration of blend components is required.
Each incoming stream is assigned to one of two priority groups. These priorities influence the optimization objective by defining the preferred order in which available components are utilized.
For every detected stream, ProductMixer creates the corresponding LP variables and incorporates its flow availability and quality properties into the optimization model. Only connected and enabled streams participate in the optimization process.

LP Model Construction

       After loading the product specifications and detecting incoming streams, ProductMixer generates the complete LP model. The model includes decision variables, material balance equations, quality constraints, density conversion equations, and the selected optimization objective.
The number of variables and constraints depends entirely on the connected streams and configured product specifications. As a result, the LP model is generated dynamically for each ProductMixer configuration without requiring manual formulation of mathematical equations.

Optimization Objectives

       ProductMixer supports two optimization modes that determine how the LP solver evaluates feasible solutions.
Maximum Product Production maximizes the amount of finished product that satisfies all quality specifications and operational constraints.
Minimum Balancing Additive Consumption minimizes the use of the balancing additive while prioritizing the utilization of higher-priority streams. The optimization objective applies weighted coefficients to residual flows, quality penalties, balancing additive consumption, and lower-priority residual streams, allowing all preferences to be evaluated within a single LP optimization.

Balancing Additive Calculation

       After the LP solver finds a feasible solution, ProductMixer calculates the required amount of balancing additive. The additive is not an independent LP decision variable but is determined from the optimized blend composition.
A single balancing additive is supported for each ProductMixer. Although it can theoretically modify multiple product properties simultaneously, its actual effect depends on the property values defined in the component database. In typical refinery applications, only the octane number has nonzero correction values, while all other property corrections are zero.
The calculated additive becomes part of the final product mass, so the total product output equals the accepted blend components plus the balancing additive.

Optimization Results

       After optimization, ProductMixer determines how each incoming stream is distributed between the finished product and residual streams.
The accepted portion of each stream is directed to the product outlet, while the remaining portion is routed to the corresponding residual outlet. Together with the calculated balancing additive, the accepted streams form the final product that satisfies all configured quality specifications.
If the LP solver cannot find a feasible solution, no product is produced. In this case, all incoming streams are directed to the residual outputs, indicating that the requested product specifications cannot be achieved under the current operating conditions.

Automatic Recalculation

       ProductMixer automatically rebuilds and resolves the LP model whenever operating conditions change. Optimization is triggered when:
  • the flow rate of any incoming stream changes;
  • the active product specification group changes (for example, due to seasonal specifications);
  • the user manually requests recalculation.
Each recalculation generates a new LP model based on the current process conditions, ensuring that the blending solution always reflects the latest stream availability and product requirements.

Conclusion

       ProductMixer automates refinery blending by generating and solving a linear programming model from the current process configuration. The optimization algorithm builds the mathematical model, evaluates all product specifications and operating constraints, calculates the optimal blend composition, determines the required balancing additive, and distributes incoming streams between product and residual outputs.
Because every optimization cycle is generated dynamically from configuration data, the same ProductMixer implementation can be applied to different refinery products without modifying the underlying optimization algorithm.

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.