2

I am trying to run the code below in VS Code for Julia (or directly on Julia). It is a simple example that computes the Maximum Likelihood estimator of the mean and the variance of a normal distribution (source):


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)

This is a nonlinear optimization problem using JuMP, and when running optimize!(mle) I am getting 'terminal process terminated with exit code 3221226356' in VS Code. Similarly, when I run it directly in Julia, it just shuts down entirely. (I have the latest versions) (I have tried in a different computer and everything works fine). Any help would be greatly appreciated!

P.S. I have seen it might have to do with a 'heap corruption problem', but I have no idea what that means/how to solve it.

Dan.phi
  • 75
  • 5
  • Heap corruption may happen if you violate bounds of (heap-allocated) array and write beyond it, i.e. use too high or too low index. – Alex Guteniev Sep 10 '21 at 16:11
  • Should not it have been a problem in the other computer I tried too? – Dan.phi Sep 10 '21 at 16:29
  • Not necessarily. Unless you use debug heap, address sanitizer, AppVerifier, or another memory debugging tool, heap corruptions may be undetected. Although consistent recreation on one machine and absence on another makes this theory less likely. Is another computer also Windows one? – Alex Guteniev Sep 10 '21 at 17:37
  • Yes, Windows too. – Dan.phi Sep 14 '21 at 16:05

1 Answers1

1

This has been cross-posted on the Julia discourse, we'll continue to debug it there: https://discourse.julialang.org/t/cant-run-simple-jump-example/67938

It's either:

  • An issue in VS-Code (although "when I run it directly in Julia" may rule this out)
  • An issue with Ipopt, which is either due to it installing an old version, or a weird incompatibility with this user's system

Either way, this is likely hard to debug.

Oscar Dowson
  • 2,395
  • 1
  • 5
  • 13