# IPOPT suppress output file generation

**URL:** <https://discourse.julialang.org/t/ipopt-suppress-output-file-generation/127595>\
**Category:** Optimization (Mathematical)\
**Created:** [April 1, 2025, 1:09pm UTC](https://discourse.julialang.org/t/ipopt-suppress-output-file-generation/127595 "2025-04-01T13:09:57Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [April 4, 2025, 2:09am UTC](https://discourse.julialang.org/t/ipopt-suppress-output-file-generation/127595/14 "2025-04-04T02:09:04Z")

</div>

@nico can you try

```julia
using Ipopt
function eval_f(x::Vector{Float64})
     return x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3]
end
function eval_g(x::Vector{Float64}, g::Vector{Float64})
     g[1] = x[1] * x[2] * x[3] * x[4]
     g[2] = x[1]^2 + x[2]^2 + x[3]^2 + x[4]^2
     return
end
function eval_grad_f(x::Vector{Float64}, grad_f::Vector{Float64})
     grad_f[1] = x[1] * x[4] + x[4] * (x[1] + x[2] + x[3])
     grad_f[2] = x[1] * x[4]
     grad_f[3] = x[1] * x[4] + 1
     grad_f[4] = x[1] * (x[1] + x[2] + x[3])
     return
end
function eval_jac_g(
     x::Vector{Float64},
     rows::Vector{Int32},
     cols::Vector{Int32},
     values::Union{Nothing,Vector{Float64}},
)
     if values === nothing
          rows .= [1, 1, 1, 1, 2, 2, 2, 2]
          cols .= [1, 2, 3, 4, 1, 2, 3, 4]
     else
          values[1] = x[2] * x[3] * x[4] # 1,1
          values[2] = x[1] * x[3] * x[4] # 1,2
          values[3] = x[1] * x[2] * x[4] # 1,3
          values[4] = x[1] * x[2] * x[3] # 1,4
          values[5] = 2 * x[1] # 2,1
          values[6] = 2 * x[2] # 2,2
          values[7] = 2 * x[3] # 2,3
          values[8] = 2 * x[4] # 2,4
     end
     return
end
function build_problem()
     prob = Ipopt.CreateIpoptProblem(
          4, # n
          [1.0, 1.0, 1.0, 1.0], # x_L
          [5.0, 5.0, 5.0, 5.0], # x_U
          2, # m
          [25.0, 40.0], # g_L
          [Inf, 40.0], # g_U
          8,
          10,
          eval_f,
          eval_g,
          eval_grad_f,
          eval_jac_g,
          nothing, # eval_h,
     )
     Ipopt.AddIpoptStrOption(prob, "hessian_approximation", "limited-memory")
     return prob
end

function Ipopt.FreeIpoptProblem(prob::Ipopt.IpoptProblem)
     if prob.ipopt_problem === C_NULL
          println("Calling FreeIpoptProblem with NULL")
          return
     end
     println("Calling FreeIpoptProblem with valid pointer")
     @ccall Ipopt.libipopt.FreeIpoptProblem(prob::Ptr{Cvoid})::Cvoid
     prob.ipopt_problem = C_NULL
     return
end
 
p1 = build_problem();
Ipopt.OpenIpoptOutputFile(p1, "ipopt.log", 5)
Ipopt.IpoptSolve(p1)
Ipopt.FreeIpoptProblem(p1)
print(read("ipopt.log", String))
p2 = build_problem();
p2.x = [1.0, 4.75, 3.82, 1.379];
Ipopt.OpenIpoptOutputFile(p2, "ipopt.log", 5)
Ipopt.IpoptSolve(p2)
Ipopt.FreeIpoptProblem(p2)
print(read("ipopt.log", String))

```

---

_[View the full topic](https://discourse.julialang.org/t/ipopt-suppress-output-file-generation/127595)._
