Julia: ctrl+c does not interrupt

Viewed 592

I'm using REPL inside VScode and trying to fix a code that gets stuck inside a certain package. I want to figure out which process is taking time by looking at the stack trace but cannot interrupt because REPL does not respond to ctrl+c. I pressed ctrl+x by accident and that showed ^X on the screen.

I am using JuMP and GLPK so it could be stuck there. However, I am not seeing any outputs.

I would also appreciate any tips on figuring out which process is causing it to be stuck.

2 Answers

Interrupts are not implemented in GLPK.jl. I've opened an issue: https://github.com/jump-dev/GLPK.jl/issues/171 (but it's unlikely to get fixed quickly).

If you're interested in contributing to JuMP, it's a good issue to get started with. You could look at the Gurobi.jl code for how we handle interrupts there as inspiration.

I started out using GLPK.jl and I also found that it would "hang" on large problems. However, I recommend trying the Cbc.jl solver. It has a time limit parameter which will interrupt the solver in a set number of seconds. I found it to produce quality results. (Or you could use Cbc for Dev/QA testing to determine what might be causing the hanging and switch to GLPK for your production runs.)

You can set the time limit using the seconds parameter as follows.

For newer package versions:

model = Model(optimizer_with_attributes(Cbc.Optimizer
                                        ,"seconds" => 60
                                        ,"threads" => 4
                                        ,"loglevel" => 0
                                        ,"ratioGap" => 0.0001))

Or like this for older package versions:

model = Model(with_optimizer(Cbc.Optimizer
                             ,seconds=60
                             ,threads=4
                             ,loglevel=0
                             ,ratioGap=0.0001))
Related