HomeContact Us
About UsProductsNewsEventsTrainingSupportPartnersKathy's Desk

102) Conditional Constraints

 A constraint is conditional if it only needs to be respected when another constraint is limiting (or not). For example, there is a maximum TAN on feed, but since sulphur buffers the metalwork, if the feed sulphur is above a certain level, the TAN limit is higher. Something like, TAN has to be less than 2, but if sulphur is greater than 0.5%, TAN can be as high as 5. The lower maximum TAN is only a constraint when the sulphur is below the minimum. The minimum sulphur only matters if the TAN is above. We can’t simply put these constraints in as specifications on the feed, or as unit parameters, because the model would see them as always required. How to model these constraints that don’t apply all the time?

A common first impulse in this situation is to set up limits on parameters in the unit – and then do something to the loading factors on the operations so that they are not constraining when the conditions are not met. For example, changing the sulphur loading from the actual feed value to an arbitrary one like 9999 so that the minimum is always met if the TAN is below 2. Changing the factor would be done by an Adherent Recursion calculation with an IF in it. However, such non-continuous conditions don’t linearize well. The optimization will have trouble predicting what happens when it crosses the boundary from one situation to another because except at that precise point, the slope is zero. Since it will mostly look like changing the inputs to the calculation has no consequences, it is quite likely to either get stuck on whichever side of the divide it tries first, or to oscillate back and forth over the threshold. So not recommended.

Blocked operation might be a good approach. You can have low TAN days with a feed pool that has a maximum of 2 and high TAN days with a feed that has a maximum acid of 5 and a minimum sulphur of 0.5%. However, it might seem a bit excessive to duplicate everything just for this feed rule, when the rest of the unit behaviour is the same. For example, all the outputs still go to the same places.

The challenge then is to model the conditional constraint within a single operating block without trying to linearize over a discontinuity. The key to doing this is to realise that it matters if the current feed quality is above or below the threshold, but the exact value is not important.   A comparison of Actual to Threshold with a balancing variable to indicate if there is excess can provide that information

Actual Tan * Total Feed - Threshold Tan * Total Feed – Tan Excess <=0

You may notice the similarity to a pool quality balance row; here the Excess vector takes the role of the error vector. This one, however, is not going to be set FREE so it can only be positive. By making the limit a minimum rather than a fix the Excess vector will only need to operate when actual TAN is higher than the threshold, rather than whenever they are different. If the Actual is lower than the threshold there is no need to run the Excess vector to compensate. A small cost on it can be used to ensure that it does not do so unless it needs to.

The “Total Feed” might be a single mode that takes a pool into the unit, or it might be a set of operations each bringing in a distinct feed, such as crudes on a main tower. The TAN associated with a feed would be picked up from the crude database or assay file for a crude, but would need to be recursed if the feed is a pool. The recursion can be set up by associating the limit with the TAN quality or setting a PUP equal to the current value – as is convenient.  The threshold is a constant so it’s the one that is convenient to set to a negative value. This could be a hard coded number in the process representation, or if the user wants to be able to adjust it, an operating parameter set to a fixed value (and carefully described as such) with a PUP set to minus that in the AR panel to bring it into the limit.

The sulphur condition, being a minmum would be

Actual Sulphur * total Feed – Sulphur Threshold * total Feed + Shortfall >=0

There are four possible combinations of TAN/Sulphur condition with respect to the thresholds: low/low, low/high, high/high and high/low. The first three are allowed so the formulation must make those feasible. High TAN with low sulphur needs to create an infeasibility.  

Let’s have a look at the quality balances for each.

102 LowLow

If the TAN is below the threshold, the Excess vector does not need to run. The Shortfall vector will be active, but it doesn’t matter.

If the Sulphur happens to above the minimum when the TAN is low, then neither the Excess nor the Shortall is active.

102 LowHigh

 If TAN is high, the Excess will be active, but if there is sufficient sulphur, the Shortfall will be zero.

102 HighHigh

Finally, If the TAN is high and the sulphur is too low, then both Excess and Shortfall vectors will have activity.

102 HighLow

This is the one that is not allowed. How to make this one infeasible without blocking the others? This is the only case where both vectors are not zero, so we need a rule to say that at most one of the two can be active. That is, we need a Special Ordered Set - an SOS – type 1.

 A conditional limit like this on the VDU in one of the demo models would have constraints like:

102 UnitLimits

Note that I’ve used the new-ish option to restrict the scope of the new limits – Tota Feed Driver, TAN check and Sulphur Check - to just the VDU. That way I can use those Names again for any other units that have the same requirement.

The operations that load the limits are:

102 UnitOperations

I’ve used PUPs to pick up the current feed qualities, but hard-coded the negative threshold values to make it easy to see them in this example.

To write the SOS, I need to know the full vector name that is generated into the matrix. You can find information about this in the reference manual, but I normally just go looking for them in the MTX or ROW files, knowing that they are going to start with location-period-unit – so RRAAVDU….

Create the SOS with the two vectors as members.

102 SOSDefintion


You can confirm that you have the right names by checking that it appears in the matrix in the SETS section, like so.

102 SOSinMTX

It will only appear if there are at least two valid members. You also have to be using the H/XPRESS optimizer. (H/CPLEX also does SOS with a slightly different format.. HSLP doesn’t support it but you can always mimic the logic using If...then structure to drive activity in binary operations.).

If the solution to the relaxed problem – the one where the MIP limits are not considered – includes activity on both of the vectors, then the branch and bound ( or the heuristics that look for solutions) will compare the value of what happens if each of the vectors is blocked in turn, so that it can carry on with the one that makes the most money. With the shortfall or excess blocked, the optimization will need to make adjustments to the feed properties in order to stay feasible. If this conditional limit is on the main tower, then the feeds are probably individual crude streams, so the slate can be rebalanced. With the constraint on the VDU as here, then the adjustment of the atres quality into the unit will be constricted by the assumed distribution factors as these and the assumed pool qualities are not updated during the MIP phase. However, if a discrepancy results, the solution will not test as converged and another pass will follow with updated assumptions. The SLP+MIP will continue until the feed TAN and sulphur arriving at the VDU are consistent with what is being produced on the CDU, and the conditional constraint is feasible.

 

From Kathy's Desk, 19th October 2026.

 

Comments and suggestions gratefully received via the usual e-mail addresses or here.
You may also use this form to ask to be added to the distribution list so that you are notified via e-mail when new articles are posted.

© Haverly Systems, Inc.
Request InfoCareersCommunityPrivacy PolicyTerms & Conditions
Contact UsSite Map