Linear Programming for Refinery Flow Allocation (part 2)

       In the first part, we discussed the general tasks and principles of building linear optimization models for simulation models of oil and gas processing facilities. In this part, we move to a practical example demonstrating how linear programming can be used to optimize the allocation of incoming flows between process lines of a unit.

Problem Formulation

       In a refinery, a process unit (Plant) may consist of one or several parallel process lines that operate according to common rules. We need to determine how the incoming flow should be allocated among the process lines and what portion, if any, will remain unaccepted. The feasible allocation depends on the feedstock type and the operating mode selected for each process line. Each mode defines a minimum and maximum throughput, while the line may also remain idle with zero flow. Therefore, for each line, the optimization must determine whether to keep it idle or operate it within its allowable throughput range. Based on these individual line constraints, the model must determine the optimal allocation of the incoming flow across the available lines and, if the total available capacity is insufficient, the resulting unaccepted flow.
Additional Constraints
       The flow allocation problem is further complicated by several practical constraints that must be incorporated into the optimization model:
       1.Additional throughput limits. The maximum throughput of a process line may be lower than its nominal capacity due to user-defined limits, catalyst constraints, reactor operating conditions, or other operational factors.
       2. Bypass flow constraints. Some process units allow part of the incoming flow to bypass the unit and be directed to other processing nodes. The bypass flow may itself be subject to constraints, such as a required minimum flow.
       3. Avoiding unnecessary switching between lines. The optimization should avoid frequent changes in allocation—for example, switching the entire flow from one line to another while leaving the other line idle. Such switching may be undesirable from an operational perspective.
       4. Minimizing the number of operating lines. Whenever possible, the required throughput should be handled by the minimum number of process lines, since operating additional lines may increase operating costs.
All these conditions must be incorporated into the optimization model to obtain a solution that is not only mathematically optimal but also operationally practical.

Mathematical Formulation of the Optimization Problem

       Consider a process unit with (N) parallel process lines. The optimization model determines the flow assigned to each line, whether the line is active, and the resulting unaccepted flow.
Let:
        — flow assigned to process line (i), (i=1,\ldots,N);
        — binary variable indicating whether process line (i) is active;
        — minimum allowable flow of line (i);
        — maximum allowable flow of line (i);
        — unaccepted (residual) flow;
        — priority penalty;
        — priority coefficient of process line (i);
        — indicator that at least one process line is active.

Objective Function

       The primary objective is to minimize the unaccepted flow. A large penalty coefficient ensures that this objective has priority over secondary optimization criteria:

where is a sufficiently large positive coefficient. The secondary term is used to introduce preferences between alternative feasible flow allocations.

Process Line Constraints

       For each process line :

.

These constraints define the operating range of each line. If , then . If , the flow must satisfy:

Thus, a process line can either remain idle or operate within its allowable minimum–maximum throughput range.

Flow Balance

       The incoming flow must be distributed between the process lines and the unaccepted flow:

Therefore, .The variable represents the portion of the incoming flow that cannot be accepted by the process unit.

Priority Constraint

       To account for preferred allocation between process lines, the model introduces a priority penalty:

The coefficients can be selected according to the required priority of the process lines. This allows the optimization to prefer one feasible allocation over another without changing the primary objective of minimizing residual flow.

Active Line Indicator

       The total number of active process lines can be represented by:

where represents the number of currently active lines.

This variable can subsequently be used to introduce additional optimization criteria, for example, to prefer solutions using fewer operating lines.

Variable Bounds

       The model also defines non-negativity constraints:

Finally, the line activation variables are binary:

The resulting model is therefore a mixed-integer linear programming (MILP) problem. Its solution simultaneously determines the operating state of each process line, the flow allocated to every line, and the minimum possible unaccepted flow for the current operating conditions of the process unit.

Optimization in the Petroleum Refining Library

       This approach is implemented directly in the Petroleum Refining Library. Whenever the incoming flow changes, the operating parameters of the process unit are updated, or the user explicitly triggers recalculation, the unit formulates and solves the defined optimization problem using its built-in wrapper around the ojAlgo optimization solver. The current incoming flow is treated as the maximum available flow, while the optimization determines the optimal flow allocated to each process line and the remaining unaccepted flow. These results are then applied to the simulation model, after which the simulation continues with the updated operating conditions.

Practical Example: Optimizing Flow Allocation Between Process Lines

      Consider a process unit with three parallel process lines. The available incoming flow is:

For each line, the selected operating mode allows a throughput from .

The optimization returns:

All three lines are active: the total accepted flow is: The resulting unaccepted flow is:

Conclusions

       This example demonstrates how linear programming can be integrated directly into refinery simulation to dynamically optimize feed flow allocation between parallel process lines. The optimization accounts for line operating limits, active and idle states, bypass flow, and operational priorities, producing a feasible allocation rather than relying on fixed rules. Implemented within the Petroleum Refining Library, this approach creates a practical link between simulation and optimization: the simulation provides the current operating conditions, while the optimization determines the best feasible allocation and returns the results directly to the model.

FAQ

1. What is the purpose of linear programming in refinery flow allocation?
Linear programming is used to determine how an incoming feed flow should be optimally allocated between parallel process lines while satisfying their operating constraints and minimizing unaccepted flow.

2. Why is mixed-integer linear programming required?
Binary variables are needed to represent the operating state of each process line. A line can either remain idle or operate within its defined minimum and maximum throughput.

3. What constraints can be included in the optimization model?
The model can account for minimum and maximum line throughput, additional capacity limits, bypass flow constraints, line priorities, operating states, and preferences for minimizing the number of active lines.

4. What is unaccepted or residual flow?
Unaccepted flow is the portion of the incoming feed that cannot be processed by the available process lines under the current operating constraints and must therefore be diverted elsewhere.

5. When is the optimization problem solved in PRL?
The optimization can be triggered by a change in incoming flow, a change in the operating parameters of the process unit, or an explicit request from the user.

6. How is the optimization problem solved in Petroleum Refining Library?
PRL formulates the optimization problem and solves it using a built-in wrapper around the ojAlgo optimization solver.

7. What does the optimization return to the simulation model?
The solver returns the optimal flow assigned to each process line and the resulting unaccepted flow. These values are then applied directly to the simulation.
8. Can the optimization handle an arbitrary number of process lines?
Yes. The mathematical formulation can be generalized to (N) parallel process lines, with each line having its own operating limits, state variables, and priority parameters.

9. How does the optimization differ from a simple flow distribution rule?
Unlike a predefined distribution rule, the optimization evaluates the complete set of constraints and selects the best feasible combination of active lines and flow rates for the current operating conditions.

10. Can this approach be used in a refinery digital twin?
Yes. The combination of dynamic simulation and optimization is well suited to refinery digital twins, where the optimal operating decision may need to be recalculated as process conditions change.