We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Reported on https://discourse.julialang.org/t/bug-in-detecting-changed-constant-in-objective-function/91235
julia> using Gurobi julia> const MOI = Gurobi.MOI MathOptInterface julia> model = Gurobi.Optimizer(); julia> x = MOI.add_variable(model) MathOptInterface.VariableIndex(1) julia> MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE) julia> attr = MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}() MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarAffineFunction{Float64}}() julia> MOI.set(model, attr, 1.0 * x - 1.0) julia> MOI.set(model, attr, 1.0 * x + 1.0) julia> MOI.get(model, attr) MathOptInterface.ScalarAffineFunction{Float64}(MathOptInterface.ScalarAffineTerm{Float64}[MathOptInterface.ScalarAffineTerm{Float64}(1.0, MathOptInterface.VariableIndex(1))], -1.0)
Final constant should be +1.0, not -1.0.
+1.0
-1.0
The text was updated successfully, but these errors were encountered:
Issue is upstream:
julia> using Gurobi julia> p = Ref{Cdouble}(NaN) Base.RefValue{Float64}(NaN) julia> envP, modelP = Ref{Ptr{Cvoid}}(), Ref{Ptr{Cvoid}}() (Base.RefValue{Ptr{Nothing}}(Ptr{Nothing} @0x0000000000000006), Base.RefValue{Ptr{Nothing}}(Ptr{Nothing} @0x000000000000000c)) julia> GRBemptyenv(envP) 0 julia> GRBstartenv(envP[]) 0 julia> GRBnewmodel(envP[], modelP, "", 0, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL) 0 julia> model = modelP[] Ptr{Nothing} @0x00007faf975b4e80 julia> GRBsetintattr(model, "ModelSense", -1) 0 julia> GRBsetdblattr(model, "ObjCon", -1.0) 0 julia> GRBupdatemodel(model) 0 julia> GRBgetdblattr(model, "ObjCon", p) 0 julia> p[] -1.0 julia> GRBsetdblattr(model, "ObjCon", 1.0) 0 julia> GRBupdatemodel(model) 0 julia> GRBgetdblattr(model, "ObjCon", p) 0 julia> p[] -1.0 julia> # Last result should be +1.0!
Sorry, something went wrong.
Closing because it is fixed in Gurobi v10:
julia> using Gurobi julia> const MOI = Gurobi.MOI MathOptInterface julia> model = Gurobi.Optimizer(); julia> x = MOI.add_variable(model) MathOptInterface.VariableIndex(1) julia> MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE) julia> attr = MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}() MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarAffineFunction{Float64}}() julia> MOI.set(model, attr, 1.0 * x - 1.0) (f.constant, ret) = (-1.0, 0) julia> MOI.set(model, attr, 1.0 * x + 1.0) (f.constant, ret) = (1.0, 0) julia> MOI.get(model, attr) MathOptInterface.ScalarAffineFunction{Float64}(MathOptInterface.ScalarAffineTerm{Float64}[MathOptInterface.ScalarAffineTerm{Float64}(1.0, MathOptInterface.VariableIndex(1))], 1.0) julia> Gurobi._GUROBI_VERSION v"10.0.0"
No branches or pull requests
Reported on https://discourse.julialang.org/t/bug-in-detecting-changed-constant-in-objective-function/91235
Final constant should be
+1.0
, not-1.0
.The text was updated successfully, but these errors were encountered: