# Can not Run nonlinear optimization example using Ipopt

**URL:** <https://discourse.julialang.org/t/can-not-run-nonlinear-optimization-example-using-ipopt/75998>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [February 8, 2022, 7:45am UTC](https://discourse.julialang.org/t/can-not-run-nonlinear-optimization-example-using-ipopt/75998 "2022-02-08T07:45:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jian\_ZUO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jian_zuo/32/33738_2.png) [@Jian\_ZUO](https://discourse.julialang.org/u/Jian_ZUO)\
**Post date:** [February 8, 2022, 7:45am UTC](https://discourse.julialang.org/t/can-not-run-nonlinear-optimization-example-using-ipopt/75998/1 "2022-02-08T07:45:26Z")

</div>

I am new to Julia and recently try to learn to do optimization using JuMP.  
I use the **Quadratically constrained programs** example in JuMP document website.

> using JuMP  
> import Ipopt  
> import Test
> 
> function example\_qcp(; verbose = true)  
> model = Model(Ipopt.Optimizer)  
> set\_silent(model)  
> @variable(model, x)  
> @variable(model, y \>= 0)  
> @variable(model, z \>= 0)  
> @objective(model, Max, x)  
> @constraint(model, x + y + z == 1)  
> @constraint(model, x \* x + y \* y - z \* z \<= 0)  
> @constraint(model, x \* x - y \* z \<= 0)  
> optimize!(model)  
> if verbose  
> print(model)  
> println("Objective value: ", objective\_value(model))  
> println("x = ", value(x))  
> println("y = ", value(y))  
> end  
> Test.@test termination\_status(model) == LOCALLY\_SOLVED  
> Test.@test primal\_status(model) == FEASIBLE\_POINT  
> Test.@test objective\_value(model) ≈ 0.32699 atol = 1e-5  
> Test.@test value(x) ≈ 0.32699 atol = 1e-5  
> Test.@test value(y) ≈ 0.25707 atol = 1e-5  
> return  
> end
> 
> example\_qcp()  
> When I run it in Jupyterlab, it says run out of memory, and I also tried vscode, it keeps  
> running without any answer.  
> How can I fix this problem to solve the optimization?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 8, 2022, 9:09am UTC](https://discourse.julialang.org/t/can-not-run-nonlinear-optimization-example-using-ipopt/75998/2 "2022-02-08T09:09:14Z")

</div>

Cannot reproduce (see below), the first run of the model takes a few seconds because of precompilation, while the second run solves in 0.01 seconds, with 2kb memory allocated so it seems unlikely that this small problem would run out of memory?

Are you on the latest versions of Julia and all packages?

```julia
julia> example_qcp()

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

Max x
Subject to
 x + y + z == 1.0
 x² + y² - z² <= 0.0
 x² - z*y <= 0.0
 y >= 0.0
 z >= 0.0
Objective value: 0.32699283491387243
x = 0.32699283491387243
y = 0.2570658388068964

(jl_JTiMl3) pkg> st
      Status `...\Temp\jl_JTiMl3\Project.toml`
  [b6b21f68] Ipopt v0.9.1
  [4076af6c] JuMP v0.22.2

julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)

```

---

<div class="post-metadata">

**Author:** ![Jian\_ZUO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jian_zuo/32/33738_2.png) [@Jian\_ZUO](https://discourse.julialang.org/u/Jian_ZUO)\
**Post date:** [February 8, 2022, 1:09pm UTC](https://discourse.julialang.org/t/can-not-run-nonlinear-optimization-example-using-ipopt/75998/3 "2022-02-08T13:09:21Z")

</div>

Thanks for the reply.  
I am using **Julia 1.7.1** , **JuMP v0.21.10** , **Ipopt v0.6.3**.

> julia\> versioninfo()  
> Julia Version 1.7.1  
> Commit ac5cc99908 (2021-12-22 19:35 UTC)  
> Platform Info:  
> OS: Linux (x86\_64-pc-linux-gnu)  
> CPU: Intel(R) Core™ i7-9750H CPU @ 2.60GHz  
> WORD\_SIZE: 64  
> LIBM: libopenlibm  
> LLVM: libLLVM-12.0.1 (ORCJIT, skylake).

I installed the Ipopt solver directly using `add Ipopt`.  
Is it because the solver I installed is old, I saw you are  
using Ipopt v0.9.1?

---

<div class="post-metadata">

**Author:** ![Jian\_ZUO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jian_zuo/32/33738_2.png) [@Jian\_ZUO](https://discourse.julialang.org/u/Jian_ZUO)\
**Post date:** [February 8, 2022, 1:48pm UTC](https://discourse.julialang.org/t/can-not-run-nonlinear-optimization-example-using-ipopt/75998/4 "2022-02-08T13:48:03Z")

</div>

I have updated JuMP and Ipopt packages.  
It’s Ok now. Before I installed several other packages  
which limits them to update to the latest version.  
I have obtained the solutions:  
Obj value: 0.32699283491387243 x= 0.32699283491387243 y= 0.2570658388068964
