# Parameters in IPOPT

**URL:** <https://discourse.julialang.org/t/parameters-in-ipopt/25908>\
**Category:** Optimization (Mathematical)\
**Created:** [July 2, 2019, 1:51am UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908 "2019-07-02T01:51:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [July 2, 2019, 1:51am UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908/1 "2019-07-02T01:51:51Z")

</div>

Dear all,  
I am with code:  
using Ipopt  
model = Model(with\_optimizer(Ipopt.Optimizer))  
@variable(model, x, start = 500)  
@variable(model, y, start = 500)  
@NLobjective(model, Min, (1 - x)^2 + 100 \* (y - x^2)^2)  
optimize!(model)  
println("x = ", value(x), " y = ", value(y))

an I want to give a maximum CPU time to solver Ipopt and a limited number of iterations. How can I do this? Where can I set the parameters in Ipopt? Anyone could help me please?

---

<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:** [July 2, 2019, 2:37am UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908/2 "2019-07-02T02:37:40Z")

</div>

See the Ipopt parameters here: [https://www.coin-or.org/Ipopt/documentation/node40.html](https://www.coin-or.org/Ipopt/documentation/node40.html)

You’re looking for

```nohighlight
Model(with_optimizer(Ipopt.Optimizer, max_cpu_time=60.0))

```

I’ve made a PR updating the documentation: [https://github.com/JuliaOpt/Ipopt.jl/pull/173](https://github.com/JuliaOpt/Ipopt.jl/pull/173)

---

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [July 2, 2019, 10:53am UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908/3 "2019-07-02T10:53:29Z")

</div>

Thank you so much for help!

---

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [July 2, 2019, 8:07pm UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908/4 "2019-07-02T20:07:22Z")

</div>

Dear,  
How can I get the solve time next the optimization?  
I have used const MOI = JuMP.MathOptInterface with solver Ipopt and tried

MOI.get(model, MOI.SolveTime()) and gives the error: ArgumentError: ModelLike of type Ipopt.Optimizer does not support accessing the attribute MathOptInterface.SolveTime()

and

getsolvetime(modelo) and give UndefVarError: getsolvetime not defined

and nothing happens.

Could you help me please?

---

<div class="post-metadata">

**Author:** ![abelsiqueira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abelsiqueira/32/47269_2.png) [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Post date:** [July 3, 2019, 3:12am UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908/5 "2019-07-03T03:12:26Z")

</div>

I believe that there is no way to get that information because IPOPT does not export it. What we did in [NLPModelsIpopt.jl](https://github.com/JuliaSmoothOptimizers/NLPModelsIpopt.jl) is to run IPOPT, capture the output, and then parse the result.

```julia
using NLPModels, NLPModelsIpopt
f(x) = (x[1] - 1)^2 + 100 * (x[2] - x[1]^2)^2
nlp = ADNLPModel(f, [500.0; 500.0])
output = ipopt(nlp)
output.elapsed_time

```

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [July 3, 2019, 12:05pm UTC](https://discourse.julialang.org/t/parameters-in-ipopt/25908/6 "2019-07-03T12:05:38Z")

</div>

For what it’s worth, [https://github.com/JuliaOpt/Ipopt.jl/pull/170](https://github.com/JuliaOpt/Ipopt.jl/pull/170) implements the `SolveTime()` attribute in Ipopt. It just puts a timer around the solve call.
