vrp icon indicating copy to clipboard operation
vrp copied to clipboard

Save full solution after every Nth iteration or accept terminal signal

Open tdeenes opened this issue 2 years ago • 4 comments

Would it be possible to save the full solution after every Nth iteration or gracefully handle a terminal signal and write out the solution at the iteration when the terminal signal was received?

This is also related to #72 . Use case: we want to let the user terminate the optimization process. Since I am not aware of any such termination criterion, what we wanted to do is to wrap vrp-cli in a loop, and pass the previous solution as the initial solution when starting the next run in the loop. When the user interrupts the process, we kill the actual vrp-cli run, but the user can still access the result of the previous run. However, 1) the initial solution file is not taken as the initial solution by vrp-cli (see #72), and 2) a SIGKILL termination criterion would be less hackish and way more ideal for us. Unfortunately I am an absolute newbie in Rust, otherwise I would try to implement this feature.

tdeenes avatar Mar 07 '22 14:03 tdeenes

Just added: https://github.com/reinterpretcat/vrp/commit/40d531e8296d5900817dc6698ba9ba82ae8b1316

reinterpretcat avatar Mar 07 '22 19:03 reinterpretcat

Great, thanks!

tdeenes avatar Mar 07 '22 22:03 tdeenes

@reinterpretcat I had to re-open this issue because the ctrl+c termination does not work if vrp-cli is started with --config. The Ctrl+C signal itself is detected, but the program is not terminated. At least if I modify the corresponding part of the ctrlc handler so that it logs when the signal it receives, I get "Received Ctrl+C!" printed to the console both with and without --config, but the program is terminated only in the latter case.

    let _ = ctrlc::set_handler({
        let should_interrupt = should_interrupt.clone();
        move || {
            println!("Received Ctrl+C!");
            should_interrupt.store(true, Ordering::Relaxed);
        }
    });

tdeenes avatar Mar 23 '22 15:03 tdeenes

ok, I will check it once I finish my current task

reinterpretcat avatar Mar 23 '22 19:03 reinterpretcat