Can't run simple JuMP example

I am learning the basics of JuMP and tried running the code below, which computes the MLE of the parameters of a Gaussian distribution (mean and variance, source):


using JuMP, Ipopt, Random, Statistics

Random.seed!(1234)

n = 1_000
data = randn(n)

mle = Model(optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0))
@NLparameter(mle, problem_data[i = 1:n] == data[i])

μ0 = randn()
σ0 = rand() + 1
@info "Starting guess, mean: $μ0, std: $σ0"

@variable(mle, μ, start = μ0)
@variable(mle, σ >= 0.0, start = σ0)

@NLexpression(mle, loglikelihood,
    -(n / 2) * (log(2π) + 2 * log(σ)) - inv(2 * σ^2) * sum((xi - μ)^2 for xi in problem_data)
)

@NLobjective(mle, Max, loglikelihood)

optimize!(mle)

It gives me the following error, however:

The terminal process "C:\Users\dan\AppData\Local\Programs\Julia-1.6.2\bin\julia.exe '-i', '--banner=no', '--project=C:\Users\dan\.julia\environments\v1.6', 'c:\Users\dan\.vscode\extensions\julialang.language-julia-1.4.0\scripts\terminalserver\terminalserver.jl', '\\.\pipe\vsc-jl-repl-96af58fe-00fa-44a6-a1c9-b3f2a023a715', '\\.\pipe\vsc-jl-cr-a2d7320e-3e0e-4bb4-8651-8e0b2284c0d8', 'USE_REVISE=true', 'USE_PLOTPANE=true', 'USE_PROGRESS=true', 'DEBUG_MODE=false'" terminated with exit code: 3221226356.

Any ideas how to fix this? Thanks!

Hi @Dan.phi,

How were you running this? This looks like an error with vs-code.

1 Like

Yes, vs code

I guess to clarify: how in VS-Code? Is your language-julia extension up-to-date?

Yes, I have Julia 1.6.2 and the Julia extension is 1.4.0.

I run it in Julia directly and it essentially closed when I hit optimize!(mle), so most likely it is not a VS Code-related issue

The example runs in Juno with Julia 1.6.2 no problem:
image
Extrapolating from here: c++ - The terminal process terminated with exit code: 3221226356 - Stack Overflow it seems that your vs code is looking for things in the wrong places.

No idea how to fix it, though.

I run it in Julia directly

From the command line REPL?

What is import Pkg; Pkg.status() and versioninfo()?

Yes, from the REPL. Also:

Please update to Ipopt.jl 0.7.0. The 0.6.3 release is more than a year old, and I’ve fixed a number of problems like this in it.

1 Like

It worked!! Thank you very much!!!

1 Like

I’m getting this exit code with Gurobi v9.0.1 after running thousands of optimizations on the same environment. I will try with v9.5

Please prefer to start a new thread, rather than posting on an old one (but you can link to the old one if helpful). The exit code is related to heap corruption, so it could be a bug in Gurobi. But it’s probably quite hard to debug if it happens only rarely in thousands of runs.