varibles take the same value but depending on the indicator variable
AnsweredHello? I am looking for how to express constraints that variables take the same value, but depends on indicator function. Say, w_1, w_2 and w_3 are the indicator function and b_1 b_2 b_3 are the corresponding variables. Want to express constraint such that if if w_i =1, then actually the corresponding variable is also the same.
I found that
-M w_i <= b_i <= M*w_i gives b_i are either 0 or some value
but want to add constraint that if b_i's are not zero, then they actually are the same.
e.g w_1 =0, w_2 =1 and w_3 =1, then b_2 = b_3
Thanks a lot!
-
Hi Changryong,
Can you give more examples? I think this may help.
- Riley
0 -
Of course, examples can be found in statistical learning, e.g lasso, but additional constraint that once the variable is nonzero, then it actually have the same value. In the above example, say b_1, b_2 and b_3 are the regression coefficient we would like to estimate, but it can take zero for sparsity. Furthermore, we would like have the same coefficient once it turns out to be non-zero. As in the above, w_1 =0, w_2 =1 and w_3 =1, then b_1=0 and b_2 = b_3. Some literature says this kind of constraint as "homogeneity pursuit".
I need to express it in a matrix
Want to solve minimize x'Qx + c'x subject to some sparse constraints Ax <= b.
Sparsity can be solved by introducing w_i's and having -M w_i < b_i < M w_i, but need additional condition
that they share the same vale for x = (b_1, b_2, b_3, w_1, w_2, w_3)'
Thanks a lot!
0 -
Hi Changryong,
Does this. from your first post, contain a mistake?
e.g w_1 =0, w_2 =1 and w_3 =0, then b_2 = b_3
The reason I was asking for more examples is I don't fully understand how this works if this does not have a mistake.
- Riley
0 -
My mistake, it should be w_1 =0, w_2=1 and w_3=1 then b_1=0, b_2 = b_3
0 -
Hi Changryong,
With Python you could use a combination of addGenConstrIndicator and addGenConstrAnd (or their shortcuts). There are similar methods in our other APIs.
So you could introduce 3 more binary variables a_{1,2}, a_{2,3}, a_{1,3} and link them like so:
a_{1,2} = w_1 and w_2
a_{2,3} = w_2 and w_3
a_{1,3} = w_1 and w_3
a_{1,2} == 1 >> b_1 == b_2
a_{2,3} == 1 >> b_2 == b_3
a_{1,3} == 1 >> b_1 == b_3I'm not sure this will result in a particularly strong model, but it should work (subject to tolerances).
- Riley
0
Please sign in to leave a comment.
Comments
5 comments