Skip to content

Difference between NChooseKConstraint and LinearConstraint on Binary Variables. #312

Answered by Osburg
Aschwins asked this question in Q&A
Discussion options

You must be logged in to vote

If I got you right you could do the following:

Add 1 NChooseKConstraint on all 15 features with max_count=5
Add the LinearInequalityConstraint x_1 + x_2 + x_3 >= c > 0 to ensure at least one feature from the first group is nonzero
Add the LinearInequalityConstraint x_3 + ... + x_15 >= c > 0 to ensure at least one feature from the second group is nonzero

This roughly follows the procedure described in #145 in case you are interested in more details, I hope this helps.
Maybe also have a look into the open issue #314 .

Cheers
Aaron :)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@jduerholt
Comment options

@jduerholt
Comment options

@Aschwins
Comment options

@Osburg
Comment options

Answer selected by R-M-Lee
@Aschwins
Comment options

@jduerholt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants