Problem Description
This is adapted from [1].
Assume we have data ai and bj:
---- 11 PARAMETER a i1 0.172, i2 0.843, i3 0.550, i4 0.301, i5 0.292, i6 0.224, i7 0.350, i8 0.856, i9 0.067 i10 0.500 ---- 11 PARAMETER b j1 0.998, j2 0.621, j3 0.992, j4 0.786, j5 0.218, j6 0.676, j7 0.244, j8 0.325, j9 0.702 j10 0.492, j11 0.424, j12 0.416, j13 0.218, j14 0.235, j15 0.630
Try to find an assignment of each ai to a unique bj such that the quantities aibj are as close to each other as possible.
This is more or less an assignment problem. The objective to make all ratios ai/bj as equal as possible, makes it interesting. I'll discuss some formulations for this problem.
We first introduce assignment variables: xi,j={1if ai is assigned to bj0otherwise The standard assignment constraints apply ∑ixi,j≤1∀j∑jxi,j=1∀i This is an "unbalanced" assignment: we have more j's than i's.
To model "all about equal", we introduce a continuous variable c that represents the common value. I.e. aibj≈cfor all (i,j) such that xi,j=1
The objective is min∑i,j[xi,j(aibj−c)]2 or min∑i,jxi,j(aibj−c)2
A complete model can look like:
When we run this model, using an MINLP solver, we see:
The assignment can be depicted as follows.
In the above matrix the cell values are celli,j=aibj
We can reformulate this MINLP model into a quadratic model by introducing variables yi,j=xi,jc This non-linear constraint can be linearized by stating xi,j=0⇒yi,j=0xi,j=1⇒yi,j=c With these y variables we can form an objective: ∑i,j(xi,jaibj−yi,j)2 Unfortunately, this is a non-convex objective. There are not many non-convex MIQP solvers around (Cplex has one). This model gives the same solutions as the MINLP model above. I am not showing the results here, as they are identical to the ones in the previous section.
We assumed here positive fractions ai/bj>0.This allows us to say c≥0 and yi,j≥0.
We can approximate the quadratic weighting of the residuals by absolute values: ∑i,j|xi,j(aibj−c)| The first thing to is to linearize the term xi,jc. As in the quadratic model, we introduce variables yi,j=xi,jc We can form the implications: xi,j=0⇒yi,j=0xi,j=1⇒yi,j=c Most solvers support indicator constraints, which allows us to implement these implications as is. If we have a solver without this, we can formulate this as a bunch of big-M constraints: −Mxi,j≤yi,j≤Mxi,jc−M(1−xi,j)≤yi,j≤c+M(1−xi,j) From the data we can assume ai≥0 and bj>0. We can exploit this: 0≤yi,j≤M1xi,jc−M2(1−xi,j)≤yi,j≤c+M2(1−xi,j) We can think a bit about good values for M1 and M2. I suggest: M1=M2=maxc=maxi,jaibj
The complete model can look like
The results look like:
The model results are very close. The assignments are the same. Just the c value and resulting sum of squared or absolute residuals are somewhat different.
The solution looks like:
A picture of this solution:
The disadvantage of this method is that it does not care about assignments as long as they are inside our optimal bandwidth. We can see this if we recalculate an optimal central c value afterwards. The results with this reconstructed c value:
Indeed, we see that the total sum of squared or absolute deviations is not as good as we saw before. The same thing can be seen by just calculating the standard deviation for the selected ratios ai/bj. This gives:
This is more or less an assignment problem. The objective to make all ratios ai/bj as equal as possible, makes it interesting. I'll discuss some formulations for this problem.
A first model
We first introduce assignment variables: xi,j={1if ai is assigned to bj0otherwise The standard assignment constraints apply ∑ixi,j≤1∀j∑jxi,j=1∀i This is an "unbalanced" assignment: we have more j's than i's.
To model "all about equal", we introduce a continuous variable c that represents the common value. I.e. aibj≈cfor all (i,j) such that xi,j=1
The objective is min∑i,j[xi,j(aibj−c)]2 or min∑i,jxi,j(aibj−c)2
A complete model can look like:
MINLP Model |
---|
min∑i,jxi,j(aibj−c)2∑jxi,j=1∀i∑ixi,j≤1∀jxi,j∈{0,1}c free |
When we run this model, using an MINLP solver, we see:
---- 33 VARIABLE x.L assignment j1 j3 j4 j5 j7 j8 j9 j10 j11 j12 i1 1.000 i2 1.000 i3 1.000 i4 1.000 i5 1.000 i6 1.000 i7 1.000 i8 1.000 i9 1.000 i10 1.000 ---- 33 VARIABLE c.L = 0.695 common value VARIABLE z.L = 0.201 objective
The assignment can be depicted as follows.
Solution. Matrix values are a(i)/b(j). |
A quadratic model
We can reformulate this MINLP model into a quadratic model by introducing variables yi,j=xi,jc This non-linear constraint can be linearized by stating xi,j=0⇒yi,j=0xi,j=1⇒yi,j=c With these y variables we can form an objective: ∑i,j(xi,jaibj−yi,j)2 Unfortunately, this is a non-convex objective. There are not many non-convex MIQP solvers around (Cplex has one). This model gives the same solutions as the MINLP model above. I am not showing the results here, as they are identical to the ones in the previous section.
Non-convex MIQP Model |
---|
min∑i,j(xi,jaibj−yi,j)2∑jxi,j=1∀i∑ixi,j≤1∀jxi,j=0⇒yi,j=0∀i,jxi,j=1⇒yi,j=c∀i,jxi,j∈{0,1}yi,j≥0c≥0 |
We assumed here positive fractions ai/bj>0.This allows us to say c≥0 and yi,j≥0.
A linear model
We can approximate the quadratic weighting of the residuals by absolute values: ∑i,j|xi,j(aibj−c)| The first thing to is to linearize the term xi,jc. As in the quadratic model, we introduce variables yi,j=xi,jc We can form the implications: xi,j=0⇒yi,j=0xi,j=1⇒yi,j=c Most solvers support indicator constraints, which allows us to implement these implications as is. If we have a solver without this, we can formulate this as a bunch of big-M constraints: −Mxi,j≤yi,j≤Mxi,jc−M(1−xi,j)≤yi,j≤c+M(1−xi,j) From the data we can assume ai≥0 and bj>0. We can exploit this: 0≤yi,j≤M1xi,jc−M2(1−xi,j)≤yi,j≤c+M2(1−xi,j) We can think a bit about good values for M1 and M2. I suggest: M1=M2=maxc=maxi,jaibj
MIP Model |
---|
min∑i,jri,j∑jxi,j=1∀i∑ixi,j≤1∀j−ri,j≤xi,jaibj−yi,j≤ri,j∀i,jyi,j≤M1xi,j∀i,jc−M2(1−xi,j)≤yi,j≤c+M2(1−xi,j)∀i,jxi,j∈{0,1}c≥0yi,j≥0ri,j≥0 |
The results look like:
---- 72 VARIABLE x.L assignment j1 j3 j4 j5 j7 j8 j9 j10 j11 j12 i1 1.000 i2 1.000 i3 1.000 i4 1.000 i5 1.000 i6 1.000 i7 1.000 i8 1.000 i9 1.000 i10 1.000 ---- 72 VARIABLE c.L = 0.711 common value ---- 72 VARIABLE y.L c*x(i,j) j1 j3 j4 j5 j7 j8 j9 j10 j11 j12 i1 0.711 i2 0.711 i3 0.711 i4 0.711 i5 0.711 i6 0.711 i7 0.711 i8 0.711 i9 0.711 i10 0.711 ---- 72 VARIABLE r.L abs(residuals) j1 j3 j4 j5 j7 j8 j9 j10 j12 i1 0.006 i2 0.139 i3 0.010 i5 0.009 i6 0.021 i7 6.137042E-4 i8 0.147 i9 0.402 i10 0.002
The model results are very close. The assignments are the same. Just the c value and resulting sum of squared or absolute residuals are somewhat different.
---- 77 PARAMETER sumdev sum of squared/absolute deviations dev^2 |dev| c minlp model 0.201 0.784 0.695 mip model 0.204 0.737 0.711
A different approach
We can look at the problem in a different way. Instead of minimize the spread around a central value c, we can minimize the bandwidth directly. I.e. we can write: minmaxv−minvminv≤aibj∀xi,j=1maxv≥aibj∀xi,j=1 These constraints can be implemented as indicator constraints xi,j=1⇒minv≤aibjxi,j=1⇒maxv≥aibj If we don't have indicator constraints available we need to resort to big-M constraints:
Alternative MIP Model |
---|
minmaxv−minv∑jxi,j=1∀i∑ixi,j≤1∀jminv≤aibj+M(1−xi,j)∀i,jmaxv≥aibj−M(1−xi,j)∀i,jxi,j∈{0,1}maxv,minv free |
The solution looks like:
---- 103 VARIABLE x.L assignment j1 j2 j3 j4 j5 j6 j9 j11 j14 j15 i1 1.000 i2 1.000 i3 1.000 i4 1.000 i5 1.000 i6 1.000 i7 1.000 i8 1.000 i9 1.000 i10 1.000 ---- 103 VARIABLE minv.L = 0.308 minimum value VARIABLE maxv.L = 0.858 maximum value
A picture of this solution:
Minimize bandwidth solution |
The disadvantage of this method is that it does not care about assignments as long as they are inside our optimal bandwidth. We can see this if we recalculate an optimal central c value afterwards. The results with this reconstructed c value:
---- 114 PARAMETER sumdev sum of squared/absolute deviations dev^2 |dev| c minlp model 0.201 0.784 0.695 mip model 0.204 0.737 0.711 mip model 2 0.313 1.548 0.617
Indeed, we see that the total sum of squared or absolute deviations is not as good as we saw before. The same thing can be seen by just calculating the standard deviation for the selected ratios ai/bj. This gives:
---- 130 PARAMETER stdev minlp model 0.149, mip model 0.149, mip model 2 0.186
Again we see this last approach leads to more variability.
In this above picture we see the results of this second MIP model not having an incentive to keep values close to each other, besides that they should be within [minv,maxv]. This model is simpler than the earlier MIP model, but we pay a price: the solution is not as highly concentrated around the central point.
![]() |
Distribution of selected a(i)/b(j) |
In this above picture we see the results of this second MIP model not having an incentive to keep values close to each other, besides that they should be within [minv,maxv]. This model is simpler than the earlier MIP model, but we pay a price: the solution is not as highly concentrated around the central point.
Non-unique bj
If we allow the bj to be reused, only a small change in the models is needed. We just need to drop the constraint ∑ixi,j≤1 When we do this, we may see a solution like:
This is turned out to be an interesting problem. A high-level MINLP problem is presented first. We can linearize the model into a MIP, but this becomes a bit messy. Modern MIP solvers offer tools (indicator constraints, built-in absolute value function) that can help here. Finally an alternative, simpler MIP model is proposed. However, this model produces solutions that are more dispersed.
Solution. Allow a column to be selected multiple times. |
Conclusion
This is turned out to be an interesting problem. A high-level MINLP problem is presented first. We can linearize the model into a MIP, but this becomes a bit messy. Modern MIP solvers offer tools (indicator constraints, built-in absolute value function) that can help here. Finally an alternative, simpler MIP model is proposed. However, this model produces solutions that are more dispersed.
No comments:
Post a Comment