# JuMP & Ipopt: failed to converge solution for standard Rosenbrock

**URL:** https://discourse.julialang.org/t/jump-ipopt-failed-to-converge-solution-for-standard-rosenbrock/125533
**Category:** Optimization (Mathematical)
**Tags:** question, jump
**Created:** [February 4, 2025, 1:48pm UTC](https://discourse.julialang.org/t/jump-ipopt-failed-to-converge-solution-for-standard-rosenbrock/125533 "2025-02-04T13:48:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![GY3090](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@GY3090](https://discourse.julialang.org/u/GY3090)
#### Post date: [February 4, 2025, 1:48pm UTC](https://discourse.julialang.org/t/jump-ipopt-failed-to-converge-solution-for-standard-rosenbrock/125533/1 "2025-02-04T13:48:16Z")

</div>

Hi everyone, I am new to Julia (and programming in general). I encountered an error while using JuMP and Ipopt to solve unconstrained maximization for a standard Rosenbrock function. It reports that “EXIT: Optimal Solution Found” but “Optimization failed or stopped early: LOCALLY\_SOLVED”. (or if directly using `value(x)` after optimization, then reported `objects of type FLOT64 are not callable`

I literally copied the codes, so I am really curious about what else can go wrong.

Any help is much appreciated!

```julia
using JuMP
using Ipopt

model = Model(Ipopt.Optimizer)

@variable(model, x, start = 0.0)
@variable(model, y, start = 0.0)

# Define the objective function
@objective(model, Min, (1 - x)^2 + 100 * (y - x^2)^2)

JuMP.optimize!(model)

if termination_status(model) == MOI.OPTIMAL
    println("Optimal value of x: ", value(x))
    println("Optimal value of y: ", value(y))
else
    println("Optimization failed or stopped early: ", termination_status(model))
end

```

---

<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: [February 4, 2025, 7:51pm UTC](https://discourse.julialang.org/t/jump-ipopt-failed-to-converge-solution-for-standard-rosenbrock/125533/2 "2025-02-04T19:51:19Z")

</div>

Hi @GY3090, welcome to the forum 😄

> I literally copied the codes, so I am really curious about what else can go wrong.

Ooo! Copied from where? We should fix the documentation.

Here’s the link to the official JuMP documentation: [Simple examples · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/simple_examples/#The-Rosenbrock-function)

There are a few things to fix with your code:

Ipopt is a local solver, so it cannot prove the solution is `OPTIMAL`. Do instead

```Julia
if termination_status(model) == LOCALLY_SOLVED
    println("Optimal value of x: ", value(x))
    println("Optimal value of y: ", value(y))
else
    println("Optimization failed or stopped early: ", termination_status(model))
end

```

There are quite a few complexities with the various statuses, so if you are new to Julia and programming, just use:

```Julia
if is_solved_and_feasible(model)
    println("Optimal value of x: ", value(x))
    println("Optimal value of y: ", value(y))
else
    println("Optimization failed or stopped early: ", termination_status(model))
end

```

Here’s what I get when I run that code:

```Julia
julia> using JuMP

julia> using Ipopt

julia> begin
           model = Model(Ipopt.Optimizer)
           @variable(model, x, start = 0.0)
           @variable(model, y, start = 0.0)
           @objective(model, Min, (1 - x)^2 + 100 * (y - x^2)^2)
           optimize!(model)
           if is_solved_and_feasible(model)
               println("Optimal value of x: ", value(x))
               println("Optimal value of y: ", value(y))
           else
               println("Optimization failed or stopped early: ", termination_status(model))
           end
       end
This is Ipopt version 3.14.17, running with linear solver MUMPS 5.7.3.

Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 3

Total number of variables............................: 2
                     variables with only lower bounds: 0
                variables with lower and upper bounds: 0
                     variables with only upper bounds: 0
Total number of equality constraints.................: 0
Total number of inequality constraints...............: 0
        inequality constraints with only lower bounds: 0
   inequality constraints with lower and upper bounds: 0
        inequality constraints with only upper bounds: 0

iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
   0 1.0000000e+00 0.00e+00 2.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
   1 9.5312500e-01 0.00e+00 1.25e+01 -1.0 1.00e+00 - 1.00e+00 2.50e-01f 3
   2 4.8320569e-01 0.00e+00 1.01e+00 -1.0 9.03e-02 - 1.00e+00 1.00e+00f 1
   3 4.5708829e-01 0.00e+00 9.53e+00 -1.0 4.29e-01 - 1.00e+00 5.00e-01f 2
   4 1.8894205e-01 0.00e+00 4.15e-01 -1.0 9.51e-02 - 1.00e+00 1.00e+00f 1
   5 1.3918726e-01 0.00e+00 6.51e+00 -1.7 3.49e-01 - 1.00e+00 5.00e-01f 2
   6 5.4940990e-02 0.00e+00 4.51e-01 -1.7 9.29e-02 - 1.00e+00 1.00e+00f 1
   7 2.9144630e-02 0.00e+00 2.27e+00 -1.7 2.49e-01 - 1.00e+00 5.00e-01f 2
   8 9.8586451e-03 0.00e+00 1.15e+00 -1.7 1.10e-01 - 1.00e+00 1.00e+00f 1
   9 2.3237475e-03 0.00e+00 1.00e+00 -1.7 1.00e-01 - 1.00e+00 1.00e+00f 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
  10 2.3797236e-04 0.00e+00 2.19e-01 -1.7 5.09e-02 - 1.00e+00 1.00e+00f 1
  11 4.9267371e-06 0.00e+00 5.95e-02 -1.7 2.53e-02 - 1.00e+00 1.00e+00f 1
  12 2.8189506e-09 0.00e+00 8.31e-04 -2.5 3.20e-03 - 1.00e+00 1.00e+00f 1
  13 9.6379889e-16 0.00e+00 8.68e-07 -5.7 9.78e-05 - 1.00e+00 1.00e+00f 1
  14 3.0814879e-29 0.00e+00 2.02e-13 -8.6 4.65e-08 - 1.00e+00 1.00e+00f 1

Number of Iterations....: 14

                                   (scaled) (unscaled)
Objective...............: 3.0814879110195774e-29 3.0814879110195774e-29
Dual infeasibility......: 2.0183854587685121e-13 2.0183854587685121e-13
Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00
Variable bound violation: 0.0000000000000000e+00 0.0000000000000000e+00
Complementarity.........: 0.0000000000000000e+00 0.0000000000000000e+00
Overall NLP error.......: 2.0183854587685121e-13 2.0183854587685121e-13

Number of objective function evaluations = 36
Number of objective gradient evaluations = 15
Number of equality constraint evaluations = 0
Number of inequality constraint evaluations = 0
Number of equality constraint Jacobian evaluations = 0
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations = 14
Total seconds in IPOPT = 0.005

EXIT: Optimal Solution Found.
Optimal value of x: 0.9999999999999899
Optimal value of y: 0.9999999999999792

```

Your `objects of type `Float64` are not callable` error is not related to the code you have posted. This happens if you have

```julia
julia> value = 1.0
1.0

julia> value(1)
ERROR: MethodError: objects of type Float64 are not callable
Maybe you forgot to use an operator such as *, ^, %, / etc. ?
Stacktrace:
[1] top-level scope
@ REPL[2]:1

```

---

<div class="post-metadata">

### Author: ![GY3090](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@GY3090](https://discourse.julialang.org/u/GY3090)
#### Post date: [February 7, 2025, 7:27am UTC](https://discourse.julialang.org/t/jump-ipopt-failed-to-converge-solution-for-standard-rosenbrock/125533/3 "2025-02-07T07:27:14Z")

</div>

I see the problem! Thank you, and it works 🙂 I copied the part from an unofficial source, so maybe there are some misunderstandings.

---

<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: [February 7, 2025, 7:58am UTC](https://discourse.julialang.org/t/jump-ipopt-failed-to-converge-solution-for-standard-rosenbrock/125533/4 "2025-02-07T07:58:54Z")

</div>

No problem. Let me know if you have any other questions.

If you’re new to Julia and programming, you may want to check out our “getting started” tutorials: [Getting started with Julia · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_julia/)
