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

[FileFormats.CBF] bug copying unsupported variable bounds to CBF #2570

Closed
odow opened this issue Oct 30, 2024 · 3 comments · Fixed by #2572
Closed

[FileFormats.CBF] bug copying unsupported variable bounds to CBF #2570

odow opened this issue Oct 30, 2024 · 3 comments · Fixed by #2572

Comments

@odow
Copy link
Member

odow commented Oct 30, 2024

Reported as https://discourse.julialang.org/t/jump-moi-wrapper-interface-problem/121776/5

julia> import MathOptInterface as MOI

julia> model = MOI.Utilities.Model{Float64}()
MOIU.Model{Float64}
├ ObjectiveSense: FEASIBILITY_SENSE
├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
├ NumberOfVariables: 0
└ NumberOfConstraints: 0

julia> x, _ = MOI.add_constrained_variable(model, MOI.GreaterThan(1.0))
(MOI.VariableIndex(1), MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(1))

julia> dest = MOI.FileFormats.CBF.Model()
MOI.FileFormats.CBF.Model
├ ObjectiveSense: FEASIBILITY_SENSE
├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
├ NumberOfVariables: 0
└ NumberOfConstraints: 0

julia> MOI.copy_to(dest, model)
MathOptInterface.Utilities.IndexMap with 2 entries:
  MOI.VariableIndex(1)                                    => MOI.VariableIndex(1)
  ConstraintIndex{VariableIndex, GreaterThan{Float64}}(1) => ConstraintIndex{VariableIndex, GreaterThan{Float64}}(1)

julia> print(dest)
Feasibility

Subject to:

VariableIndex-in-GreaterThan{Float64}
@blegat
Copy link
Member

blegat commented Oct 30, 2024

I'm not sure to understand why we need this. If it's not supported, add_constraint is already throwing UnsupportedConstraint so we shouldn't have to call supports_constraint. If the model does not throw correctly then the model should be fixed, we should not complicate copy_to just to make bugs occur less frequently (as they will still appear if the user calls add_constraint directly).

@odow
Copy link
Member Author

odow commented Oct 30, 2024

Okay, I guess we could fix this in GenericModel then.

@odow
Copy link
Member Author

odow commented Oct 30, 2024

Closed by #2572

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