Motivated by a recent question on OR-Exchange, this post expands on a previous post about constraints that set a variable equal to the maximum or minimum of other variables in a mathematical program. Here I'll deal with inequality bounds (and with more than two variables involved in the maximum/minimum).
The setting is a mathematical programming model containing variables x1,…,xn and y, where you want to bound y either above or below by either maxi=1,…,nxi or mini=1,…,nxi. Let's dispense with the easy cases first. Since
y≥maxi=1,…,nxi⟺y≥xi∀i=1,…,ny≤mini=1,…,nxi⟺y≤xi∀i=1,…,n
those two cases are handled by expanding one nonlinear inequality into n linear inequalities, with no requirement that the variables be bound and no introduction of integer variables.
Now let's consider the case y≤maxi=1,…,nxi. (The case y≥mini=1,…,nxi is symmetric and left to the reader as an exercise.) The key to our approach is that y≤maxi=1,…,nxi⟺∃i∋y≤xi.To handle this case, we need a priori bounds on the x variables, say Li≤xi≤Ui ∀i. Let ˉU=maxi=1,…,nUi, and note that if the constraint y≤maxi=1,…,nxi is to hold, then clearly y≤ˉU.
We introduce binary variables δ1,…,δn and the constraint δ1+⋯+δn=1.Depending on the solver being used, it may be beneficial to specify to the solver that the δ variables form a type 1 special ordered set (SOS1). Now add the following n constraints:y≤xi+(ˉU−Li)(1−δi) ∀i=1,…,n.If δi=0, the right hand side becomes xi+ˉU−Li≥ˉU, and the constraint is vacuous. For the one index where δi=1, the constraint reduces to y≤xi, which is all we need.
Addendum 1: It belatedly occurred to me that it would be equally valid to replace δ1+⋯+δn=1 with δ1+⋯+δn≥1 (in which case it is no longer an SOS1 constraint). Requiring y≤maxi=1,…,nxi is equivalent to saying y≤x1 OR y≤x2 OR ... OR y≤xn, with the ors being inclusive. I have no idea whether this second version is more or less efficient computationally than using the SOS1 constraint.
Addendum 2: Erwin Kalvelagen posted some alternative, possibly tighter, formulations on his blog.
No comments:
Post a Comment
Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.