# Query solving time in JuMP v0.19

**URL:** <https://discourse.julialang.org/t/query-solving-time-in-jump-v0-19/21806>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [March 13, 2019, 7:17am UTC](https://discourse.julialang.org/t/query-solving-time-in-jump-v0-19/21806 "2019-03-13T07:17:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WangQuanmeng](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@WangQuanmeng](https://discourse.julialang.org/u/WangQuanmeng)\
**Post date:** [March 13, 2019, 7:17am UTC](https://discourse.julialang.org/t/query-solving-time-in-jump-v0-19/21806/1 "2019-03-13T07:17:46Z")

</div>

Hi guys,

I just updated to JuMP v.019, and notice `getsolvetime` is removed.

I did not find the updated function in [JuMP doc](http://www.juliaopt.org/JuMP.jl/latest/). So I turn to [MOI doc](http://www.juliaopt.org/MathOptInterface.jl/dev/apimanual/#A-complete-example:-solving-a-knapsack-problem-1), where I find the example of `MOI.get(optimizer, MOI.TerminationStatus())`.

I tried this on a simple example on my PC,

```julia
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

```julia
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

```julia
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?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 13, 2019, 12:20pm UTC](https://discourse.julialang.org/t/query-solving-time-in-jump-v0-19/21806/2 "2019-03-13T12:20:18Z")

</div>

> MethodError: no method matching get(::Int64, ::MathOptInterface.SolveTime)

This suggests that you are passing `m[k]` is an `Int64`.

As one potential problem, it looks like you initialize `k=10` models, but look through `k=100` models in the second loop.

It is hard to say anything else without a minimal working example (MWE). See:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![WangQuanmeng](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@WangQuanmeng](https://discourse.julialang.org/u/WangQuanmeng)\
**Post date:** [March 13, 2019, 12:32pm UTC](https://discourse.julialang.org/t/query-solving-time-in-jump-v0-19/21806/3 "2019-03-13T12:32:53Z")

</div>

Thanks very much for the reply, and I get your message on `Int64`.

I just realize I made some syntax error… it is not a problem of julia or JuMP.

I tried to delete my post but turns out I am not allowed to do so 😂

Sorry for posting such a silly question 😅

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 13, 2019, 1:24pm UTC](https://discourse.julialang.org/t/query-solving-time-in-jump-v0-19/21806/4 "2019-03-13T13:24:41Z")

</div>


