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

ConstraintIndex starts from 2 #522

Closed
WalterMadelim opened this issue Oct 19, 2023 · 2 comments · Fixed by #523
Closed

ConstraintIndex starts from 2 #522

WalterMadelim opened this issue Oct 19, 2023 · 2 comments · Fixed by #523

Comments

@WalterMadelim
Copy link

Are there any justification for labeling a very first ScalarAffineFunction constraint in an optimizer to be 2, rather than 1?

import MathOptInterface as MOI
import Gurobi
o = Gurobi.Optimizer()
x = MOI.add_variable(o)
f = MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.,x)], 0.)
s = MOI.GreaterThan(1.)
# Notice the output: Can explain why this number starts from 2 here?
println(MOI.add_constraint(o,f,s)) # MathOptInterface.ConstraintIndex{...}(2)
# ... = MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.GreaterThan{Float64}
@blegat
Copy link
Member

blegat commented Oct 19, 2023

The MOI implementations can use any constraint indices as long as they don't overlap. However, this might be unintended behavior here, see #523

@blegat blegat transferred this issue from jump-dev/MathOptInterface.jl Oct 19, 2023
@WalterMadelim
Copy link
Author

Thanks. I'm now writing integer programming algorithms with MOI. It fulfills my need :)

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

Successfully merging a pull request may close this issue.

2 participants