---- 57 ***baseline*** VARIABLE z.L = 0.672 objective ---- 57 VARIABLE x.L fractions i1 0.301, i2 0.138, i6 0.006, i7 0.081, i8 0.222, i9 0.077, i10 0.066, i12 0.109
All possible combinations
---- 68 SET combinations3 all possible 3-combinations i1 .i2 .i3 , i1 .i2 .i4 , i1 .i2 .i5 , i1 .i2 .i6 , i1 .i2 .i7 , i1 .i2 .i8 i1 .i2 .i9 , i1 .i2 .i10, i1 .i2 .i11, i1 .i2 .i12, i1 .i3 .i4 , i1 .i3 .i5 i1 .i3 .i6 , i1 .i3 .i7 , i1 .i3 .i8 , i1 .i3 .i9 , i1 .i3 .i10, i1 .i3 .i11 i1 .i3 .i12, i1 .i4 .i5 , i1 .i4 .i6 , i1 .i4 .i7 , i1 .i4 .i8 , i1 .i4 .i9 i1 .i4 .i10, i1 .i4 .i11, i1 .i4 .i12, i1 .i5 .i6 , i1 .i5 .i7 , i1 .i5 .i8 i1 .i5 .i9 , i1 .i5 .i10, i1 .i5 .i11, i1 .i5 .i12, i1 .i6 .i7 , i1 .i6 .i8 i1 .i6 .i9 , i1 .i6 .i10, i1 .i6 .i11, i1 .i6 .i12, i1 .i7 .i8 , i1 .i7 .i9 i1 .i7 .i10, i1 .i7 .i11, i1 .i7 .i12, i1 .i8 .i9 , i1 .i8 .i10, i1 .i8 .i11 i1 .i8 .i12, i1 .i9 .i10, i1 .i9 .i11, i1 .i9 .i12, i1 .i10.i11, i1 .i10.i12 i1 .i11.i12, i2 .i3 .i4 , i2 .i3 .i5 , i2 .i3 .i6 , i2 .i3 .i7 , i2 .i3 .i8 i2 .i3 .i9 , i2 .i3 .i10, i2 .i3 .i11, i2 .i3 .i12, i2 .i4 .i5 , i2 .i4 .i6 i2 .i4 .i7 , i2 .i4 .i8 , i2 .i4 .i9 , i2 .i4 .i10, i2 .i4 .i11, i2 .i4 .i12 i2 .i5 .i6 , i2 .i5 .i7 , i2 .i5 .i8 , i2 .i5 .i9 , i2 .i5 .i10, i2 .i5 .i11 i2 .i5 .i12, i2 .i6 .i7 , i2 .i6 .i8 , i2 .i6 .i9 , i2 .i6 .i10, i2 .i6 .i11 i2 .i6 .i12, i2 .i7 .i8 , i2 .i7 .i9 , i2 .i7 .i10, i2 .i7 .i11, i2 .i7 .i12 i2 .i8 .i9 , i2 .i8 .i10, i2 .i8 .i11, i2 .i8 .i12, i2 .i9 .i10, i2 .i9 .i11 i2 .i9 .i12, i2 .i10.i11, i2 .i10.i12, i2 .i11.i12, i3 .i4 .i5 , i3 .i4 .i6 i3 .i4 .i7 , i3 .i4 .i8 , i3 .i4 .i9 , i3 .i4 .i10, i3 .i4 .i11, i3 .i4 .i12 i3 .i5 .i6 , i3 .i5 .i7 , i3 .i5 .i8 , i3 .i5 .i9 , i3 .i5 .i10, i3 .i5 .i11 i3 .i5 .i12, i3 .i6 .i7 , i3 .i6 .i8 , i3 .i6 .i9 , i3 .i6 .i10, i3 .i6 .i11 i3 .i6 .i12, i3 .i7 .i8 , i3 .i7 .i9 , i3 .i7 .i10, i3 .i7 .i11, i3 .i7 .i12 i3 .i8 .i9 , i3 .i8 .i10, i3 .i8 .i11, i3 .i8 .i12, i3 .i9 .i10, i3 .i9 .i11 i3 .i9 .i12, i3 .i10.i11, i3 .i10.i12, i3 .i11.i12, i4 .i5 .i6 , i4 .i5 .i7 i4 .i5 .i8 , i4 .i5 .i9 , i4 .i5 .i10, i4 .i5 .i11, i4 .i5 .i12, i4 .i6 .i7 i4 .i6 .i8 , i4 .i6 .i9 , i4 .i6 .i10, i4 .i6 .i11, i4 .i6 .i12, i4 .i7 .i8 i4 .i7 .i9 , i4 .i7 .i10, i4 .i7 .i11, i4 .i7 .i12, i4 .i8 .i9 , i4 .i8 .i10 i4 .i8 .i11, i4 .i8 .i12, i4 .i9 .i10, i4 .i9 .i11, i4 .i9 .i12, i4 .i10.i11 i4 .i10.i12, i4 .i11.i12, i5 .i6 .i7 , i5 .i6 .i8 , i5 .i6 .i9 , i5 .i6 .i10 i5 .i6 .i11, i5 .i6 .i12, i5 .i7 .i8 , i5 .i7 .i9 , i5 .i7 .i10, i5 .i7 .i11 i5 .i7 .i12, i5 .i8 .i9 , i5 .i8 .i10, i5 .i8 .i11, i5 .i8 .i12, i5 .i9 .i10 i5 .i9 .i11, i5 .i9 .i12, i5 .i10.i11, i5 .i10.i12, i5 .i11.i12, i6 .i7 .i8 i6 .i7 .i9 , i6 .i7 .i10, i6 .i7 .i11, i6 .i7 .i12, i6 .i8 .i9 , i6 .i8 .i10 i6 .i8 .i11, i6 .i8 .i12, i6 .i9 .i10, i6 .i9 .i11, i6 .i9 .i12, i6 .i10.i11 i6 .i10.i12, i6 .i11.i12, i7 .i8 .i9 , i7 .i8 .i10, i7 .i8 .i11, i7 .i8 .i12 i7 .i9 .i10, i7 .i9 .i11, i7 .i9 .i12, i7 .i10.i11, i7 .i10.i12, i7 .i11.i12 i8 .i9 .i10, i8 .i9 .i11, i8 .i9 .i12, i8 .i10.i11, i8 .i10.i12, i8 .i11.i12 i9 .i10.i11, i9 .i10.i12, i9 .i11.i12, i10.i11.i12
---- 113 SET comb combinations
i1 i2 i3 i4 i5 i6 i7 i8 i9
n1 YES YES YES
n2 YES YES YES
n3 YES YES YES
n4 YES YES YES
n5 YES YES YES
n6 YES YES YES
n7 YES YES YES
n8 YES YES
n9 YES YES
n10 YES YES
n11 YES YES YES
n12 YES YES YES
n13 YES YES YES
n14 YES YES YES
n15 YES YES YES
n16 YES YES YES
n17 YES YES
n18 YES YES
n19 YES YES
n20 YES YES YES
. . .
Note that this is a partial view. We can easily generate these combinations with a bit of Python code. itertools.combinations is our friend here. With this set we can write: ∑i|combn,ixi≤0.5∀n The structure does not change if we use a different value for K.
When we run one of these models, we see:
---- 75 ***all combinations*** VARIABLE z.L = 0.760 objective ---- 75 VARIABLE x.L fractions i1 0.160, i2 0.139, i3 0.001, i7 0.101, i8 0.201, i9 0.121, i10 0.139, i12 0.139
The objective (risk) deteriorated from 0.672 to 0.760. The sum of the K=3 largest allocations is binding at 0.201+0.160+0.139=0.5.
Obviously, the number of constraints can become rather large. E.g. for N=100,K=3, we have(NK)=(1003)=161,700
An integer formulation
---- 154 ***MIQP model*** VARIABLE z.L = 0.760 objective ---- 154 VARIABLE x.L fractions i1 0.160, i2 0.139, i3 0.001, i7 0.101, i8 0.201, i9 0.121, i10 0.139, i12 0.139
Compact formulation
---- 177 ***compact formulation*** VARIABLE z.L = 0.760 objective ---- 177 VARIABLE x.L fractions i1 0.160, i2 0.139, i3 0.001, i7 0.101, i8 0.201, i9 0.121, i10 0.139, i12 0.139
Notes
- Here we used "sum of k largest" in a ≤ constraint. It is also applicable when it appears in an objective, as long as we are minimizing (when maximizing, things become non-convex).
- If you want to minimize (or constrain) just the k-th largest, use the MIP formulation. I have seen such a construct used in some financial models because of regulatory frameworks.
References
- Stephen Boyd, Lieven Vandenberghe, Convex Optimization, 2004, Exercise 5.19.
Appendix: GAMS code
$onText import itertools |
A somewhat intuitive interpretation of the compact formulation is that t represents the Kth largest value, which gets counted K times, and u_i = max(x_i - t, 0) represents the amount by which x_i exceeds t, to account for the rest of the sum of the K largest values.
ReplyDelete