Manual Product Blending Algorithm

       The Manual Product Blending Algorithm is an operating mode of the ProductMixer component that produces blended products according to predefined blend ratios. These predefined coefficients are calculated based on the properties of the inlet streams to ensure that the final blended product satisfies the required quality specifications. Instead of optimizing the blend composition, ProductMixer follows a user-defined recipe and continuously adjusts component flow rates to maintain the specified proportions throughout the simulation.
       This approach is commonly used to simulate fixed refinery blending recipes, reproduce historical operating conditions, validate predefined blend scenarios, and model processes where blend composition is determined by operational requirements rather than mathematical optimization. The algorithm is suitable for refinery product blending, fuel blending, and other petroleum refining applications where the blending strategy must be fully customized.

How the Manual Product Blending Algorithm Works

       In the manual operating mode, the ProductMixer does not calculate an optimal blend composition. Instead, the user defines an optimization model that determines how inlet streams are distributed. During the simulation, the component continuously regulates the inlet flow rates to preserve these predefined blending ratios while respecting the maximum capacity of the mixer and the availability of each incoming stream. If one or more inlet streams cannot supply the required flow, the total production rate is reduced accordingly. The specified blend ratios remain unchanged unless they are modified by the user during the simulation. This approach enables engineers to implement custom blend recipes and advanced refinery blending strategies while preserving material balance throughout the simulation. The blend ratios are determined based on the properties of the inlet streams to ensure that the final blend satisfies the required product specifications.

ProductMixer Optimization Variables

       ProductMixer exposes a predefined set of optimization variables that represent the accepted and rejected portions of each inlet stream. The optimization model must use these variable names exactly as defined in the internal Constants class. After the optimization problem is solved, ProductMixer automatically reads the calculated values and updates the corresponding flow rates in the simulation.

The most frequently used variables include:
  • Accepted inlet flow – FLOW_MASS_LABEL + productId
  • Rejected inlet flow – FLOW_MASS_RESIDUAL_LABEL + productId
  • Total product flow – FLOW_MASS_PRODUCT_LABEL+ productId
       These variables represent the interface between the optimization model and ProductMixer. Using the predefined variable names ensures that ProductMixer can correctly map the optimization results back to the simulation model. Custom variable names may be added to the optimization problem, but they are ignored by ProductMixer and can only be used internally within the optimization model.

Defining the Blending Strategy

       The manual blending algorithm places no restrictions on the optimization model itself. Users are free to define any objective function and any set of linear constraints that describe their blending strategy. This flexibility allows the algorithm to represent a wide range of refinery operating scenarios, from simple fixed-ratio blending to complex production planning problems. Typical optimization objectives include maximizing product throughput, minimizing the consumption of high-value blending components, minimizing operating costs, or maximizing production profit. The optimization model may also include constraints on component flow rates, product quality, equipment capacities, material availability, or any other process-specific requirements. Typical applications include gasoline blending, diesel blending, intermediate product blending, and refinery production planning. Because the optimization model is fully user-defined, the manual blending algorithm can be adapted to virtually any linear blending problem encountered in refinery process simulation.
       The following workflow illustrates how a user-defined optimization model is processed by ProductMixer during the simulation.

Implementing Manual Blending in Petroleum Refining Library

       The manual blending algorithm is implemented by defining a custom optimization problem. Before each recalculation, ProductMixer invokes the manualOptimizationProblem() callback, where the user receives an instance of the Problem class from the JavaILP library. ProductMixer is solver-independent and can execute any optimization model compatible with the supported linear programming interface. This library is included in both Petroleum Refining Library for Anylogic and ProductMixer and is used to describe the optimization model. When creating the optimization problem, all variables representing ProductMixer flows must use the predefined variable names defined in the internal Constants class. This allows ProductMixer to interpret the optimization results correctly. For example, the variable representing the accepted mass flow of an inlet product should be created as:
String inputFlowName = productMixer.constants.FLOW_MASS_LABEL + productId;
       After the optimization problem is defined, ProductMixer automatically solves it and distributes each inlet stream into accepted and rejected flow portions according to the calculated solution. If the optimization problem has no feasible solution, all incoming streams are automatically redirected to the rejected flow outputs, ensuring that no invalid blend is produced.

Automatic vs. Manual Product Blending

  •        The ProductMixer component supports both Automatic and Manual blending algorithms. The automatic algorithm provides a ready-to-use optimization strategy for standard refinery blending tasks, while the manual algorithm allows users to define the optimization model themselves for maximum flexibility.

Advantages of the Manual Product Blending Algorithm

       The Manual Product Blending Algorithm offers several advantages over predefined blending approaches:
  • Complete optimization control – Users define the objective function, decision variables, and constraints without being limited to a predefined optimization strategy.
  • Flexible refinery blending strategies – The algorithm can represent virtually any linear blending problem, from fixed blend recipes to complex refinery optimization scenarios.
  • Custom optimization objectives – Models can maximize product throughput, minimize operating costs, maximize profit, or optimize any other linear objective.
  • Support for process-specific constraints – Operational limits, product quality specifications, equipment capacities, material availability, and company-specific rules can all be incorporated into the optimization model.
  • Seamless integration with ProductMixer – After the optimization problem is solved, ProductMixer automatically applies the calculated solution and updates all accepted and rejected flow streams.
  • Dynamic operation – The optimization model can be regenerated during simulation, allowing the blending strategy to adapt to changing operating conditions.
  • Rapid development and testing – Engineers can prototype and validate new blending strategies without modifying the internal ProductMixer algorithm.

Conclusion

       The Manual Product Blending Algorithm provides a flexible framework for implementing custom blending strategies in refinery process simulations. Instead of relying on a predefined optimization model, users define the objective function, decision variables, and operational constraints that best represent their blending process.
       This approach makes it possible to model virtually any linear blending problem while keeping the optimization fully integrated with the simulation. For applications where the blending logic follows standard refinery objectives, the Automatic Product Blending Algorithm offers a ready-to-use solution. When custom optimization strategies are required, the manual algorithm provides complete control over refinery product blending and custom blend optimization strategies.

FAQ

1. What is the Manual Product Blending Algorithm?
The Manual Product Blending Algorithm is a blending mode in which the optimization model is fully defined by the user. Instead of relying on a built-in optimization strategy, users specify the objective function, decision variables, and constraints that determine how inlet streams are blended.

2. When should the manual algorithm be used?
The manual algorithm is appropriate when the required blending strategy cannot be represented by the standard automatic algorithm. Typical examples include custom operating rules, company-specific optimization objectives, or specialized process constraints.

3. Can I define my own optimization objective?
Yes. The optimization objective is completely user-defined. It may maximize product throughput, minimize blending costs, maximize profit, reduce the consumption of specific components, or optimize any other linear objective.

4. What types of constraints can be included?
Any linear constraints supported by the selected optimization solver can be used. These typically include flow balance equations, capacity limits, product quality requirements, component availability, and other operational constraints.

5. What happens if no feasible solution is found?
If the optimization problem has no feasible solution, no valid blend is produced. The incoming material is routed to the rejected flow streams, ensuring that the simulation remains physically consistent.

6. Does the manual algorithm support linear programming only?
Yes. The current implementation is designed for linear optimization problems. Nonlinear blending problems must be reformulated as linear models or solved using an external optimization approach.

7. Can the optimization model change during the simulation?
Yes. The optimization problem may be rebuilt whenever operating conditions change, allowing the blending strategy to adapt dynamically to new process conditions, production targets, or material availability.

8. Can the Manual Product Blending Algorithm be used for gasoline or diesel blending?
Yes. The algorithm can be used for gasoline blending, diesel blending, jet fuel blending, and any other refinery product that can be represented by a linear optimization model.

9. Can the Manual Product Blending Algorithm be integrated with refinery process simulation models?
Yes. The algorithm is fully integrated with refinery process simulation and digital twin models developed using the Petroleum Refining Library.