-
Notifications
You must be signed in to change notification settings - Fork 40
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
ModelLike of type Alpine.Optimizer does not support accessing the attribute MathOptInterface.ResultCount() #162
Comments
@OliverEvans96 Are you getting this issue with other MILP solvers like CPLEX/Gurobi? |
Looking at the code, Line 583 in 383bdbc
A simple implementation is MOI.get(model::Optimizer, ::MOI.ResultCount) = model.alpine_status == MOI.OPTIMIZE_NOT_CALLED ? 0 : 1 #152 should help catching these kind of issues |
@harshangrjn I don't have CPLEX/Gurobi. @blegat when I define your julia> value(x)
ERROR: The index MathOptInterface.VariableIndex(1) is invalid. Note that an index becomes invalid after it has been deleted.
Stacktrace:
[1] throw_if_not_valid(::Alpine.Optimizer, ::MathOptInterface.VariableIndex) at /home/oliver/.julia/packages/MathOptInterface/ZJFKw/src/indextypes.jl:75
[2] get(::Alpine.Optimizer, ::MathOptInterface.VariablePrimal, ::MathOptInterface.VariableIndex) at /home/oliver/.julia/packages/Alpine/Z4PGO/src/solver.jl:584
[3] get(::MathOptInterface.Bridges.LazyBridgeOptimizer{Alpine.Optimizer}, ::MathOptInterface.VariablePrimal, ::MathOptInterface.VariableIndex) at /home/oliver/.julia/packages/MathOptInterface/ZJFKw/src/Bridges/bridge_optimizer.jl:808
[4] get(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.VariablePrimal, ::MathOptInterface.VariableIndex) at /home/oliver/.julia/packages/MathOptInterface/ZJFKw/src/Utilities/cachingoptimizer.jl:605
[5] _moi_get_result(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.VariablePrimal, ::Vararg{Any,N} where N) at /home/oliver/.julia/packages/JuMP/qhoVb/src/JuMP.jl:848
[6] get(::Model, ::MathOptInterface.VariablePrimal, ::VariableRef) at /home/oliver/.julia/packages/JuMP/qhoVb/src/JuMP.jl:878
[7] value(::VariableRef; result::Int64) at /home/oliver/.julia/packages/JuMP/qhoVb/src/variables.jl:767
[8] value(::VariableRef) at /home/oliver/.julia/packages/JuMP/qhoVb/src/variables.jl:767
[9] top-level scope at REPL[11]:1 |
You should also add MOI.is_valid(model::Optimizer, vi::MOI.VariableIndex) = 1 <= vi.value <= model.num_var_orig |
@blegat - that worked! julia> value(x)
-1.0 Thanks and happy holidays! |
This issue has been fixed in v0.2.2. |
Hello,
I'm having trouble accessing the optimal variable value from an Alpine model. Possibly related to #101.
Minimal Example
An optimal solution is reached:
Solver Output
Error Message
But when I try try to access the value, of
x
, I get the following error:Relevant Package Versions
Using Julia v1.5.3 (2020-11-09)
Is there currently any way to get the variable value?
Thanks!
Oliver
The text was updated successfully, but these errors were encountered: