Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operational constraints not working #30

Open
juanhu96 opened this issue Dec 6, 2023 · 1 comment
Open

Operational constraints not working #30

juanhu96 opened this issue Dec 6, 2023 · 1 comment

Comments

@juanhu96
Copy link

juanhu96 commented Dec 6, 2023

Hi there,

I'm currently applying riskSLIM to a problem of mine and am trying to implement operational constraints in the form of 'At least one of A or B must be selected'. However, I've noticed that riskSLIM seems to only accommodate constraints of the type 'At most one of A or B can be selected'. To address this, I attempted to add the 'at least one' constraint with the following three versions of code:

`cons.add(
lin_expr = [SparsePair(ind = get_alpha_ind(constraint), val = [1.0]*len(constraint))],
senses = "E",
rhs = [1.0]
)

cons.add(
lin_expr = [SparsePair(ind = get_alpha_ind(constraint), val = [1.0]*len(constraint))],
senses = "G",
rhs = [1.0]
)

cons.add(
lin_expr = [SparsePair(ind = get_alpha_ind(constraint), val = [-1.0]*len(constraint))],
senses = "L",
rhs = [-1.0]
)`

but none worked. Although these constraints are successfully added to the CPLEX model (I printed out the entire model to confirm), the resulting scoring tables consistently violate these specific constraints. I've spent a quite a few time examining the code, yet I'm unable to determine why this isn't working. Is this a limitation of the model itself, or is there something I'm overlooking?

Any helps would greatly appreciated. Thanks!

@BopGau17
Copy link

Hi there! I'm currently new to this topic and also trying to implement the same constraint that you want here. Does it help if you try a linear constraint like the second version again?

cons.add(
lin_expr = [SparsePair(ind = get_alpha_ind(["A", "B"]), val = [1.0, 1.0]],
senses = ["G"]
rhs = [1.0]
)

To my knowledge this should work, since this basically forces alpha_A + alpha_B >= 1.0 and this constraint is only satisfied if one of the alphas is 1.0 or both of them are 1.0

I would appreciate your answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants