Hi guys,
I just updated to JuMP v.019, and notice getsolvetime
is removed.
I did not find the updated function in JuMP doc. So I turn to MOI doc, where I find the example of MOI.get(optimizer, MOI.TerminationStatus())
.
I tried this on a simple example on my PC,
using JuMP,Gurobi,MathOptInterface
env = Gurobi.Env()
m = Vector{Model}( undef, 3 )
m[ 1 ] = Model( with_optimizer( Gurobi.Optimizer , env ) )
@variable( m[ 1 ] , b[ 1:5 ] >= 0 )
@constraint( m[ 1 ] , b[ 1 ] >= 1 )
@objective( m[ 1 ] , Min , b[ 3 ] )
JuMP.optimize!( m[ 1 ] )
println( MathOptInterface.get( m[ 1 ] , MathOptInterface.SolveTime( ) ) )
And julia runs the program and report solving time correctly.
But when I turns in to a more complicated program I meet some errors
m = Vector{Model}( undef, 10 )
# add variables and constraints
# to define feasible region for each subproblem
for k in 1:10
m[ k ] = Model( with_optimizer( Gurobi.Optimizer , env ) )
@variable( m[ k ] , c )
end
# outter loop for update lagrangian dual variables
for it in 1:50
set up lagrangian dual variable \lambda
# inner loop for solving decomposed subproblem
# with modified objective
for k in 1:100
c = m[ k ][ :c ]
@objective( m[ k ] , Min , c - \lambda )
JuMP.optimize!( m[ k ] )
println( MathOptInterface.get( m[ k ] , MathOptInterface.SolveTime() ) )
end
end
The error is
ERROR: LoadError: MethodError: no method matching get(::Int64, ::MathOptInterface.SolveTime)
Closest candidates are:
get(::Model, ::MathOptInterface.AbstractModelAttribute) at C:\Users\tommyricardo\.julia\packages\JuMP\jnmGG\src\JuMP.jl:593
get(::MathOptInterface.Utilities.MockOptimizer, ::MathOptInterface.AbstractModelAttribute) at C:\Users\tommyricardo\.julia\packages\MathOptInterface\5SeJM\src\Utilities\mockoptimizer.jl:167
get(::MathOptInterface.Utilities.CachingOptimizer, ::MathOptInterface.AbstractModelAttribute) at C:\Users\tommyricardo\.julia\packages\MathOptInterface\5SeJM\src\Utilities\cachingoptimizer.jl:420
...
Stacktrace:
[1] top-level scope at C:\Users\tommyricardo\.julia\packages\JuMP\jnmGG\src\macros.jl:279
[2] top-level scope at F:\a__top_secret\lagrangian_relaxation_TypeExperiment_SingleUnitQIP.jl:177
in expression starting at F:\a__top_secret\lagrangian_relaxation_TypeExperiment_SingleUnitQIP.jl:171
Can anyone help to explain this? Or provide some methods of query solving time in JuMP?