The VS Code debugger always gets stuck at the quadratic constraint definition of a JuMP model

The VS Code debugger always gets stuck at the quadratic constraint definition of a JuMP model. Please launch the debugger to run the following code in the VS Code in an environment where JuMP.jl is installed:

using Pkg
Pkg.activate(".")

using JuMP
model = Model()
N = 300
P = rand(N, N)
@variable(model, x[1:N])
@constraint(model, con, x' * P * x >= 0) # The debugger will get stuck at here
println("Over")

What’s the reason? And, how do you debug in VS Code?

P.S. If N = 3, it will not get stuck. But 300 is not too large since one can run the code very fast without launching the debugger.

1 Like

The debugger runs in interpreter mode which can be much slower than compiled code. Infiltrator.jl preserves execution speed, though it’s not a full replacement for a stepping debugger, and last time I checked, it has compatibility problems when it’s run in VSCode rather than the terminal REPL.

2 Likes

True, but you can always work around that by running your code in the integrated terminal instead of using inline evaluation in the editor.

2 Likes