rust-or / lp-solvers

library implementing interaction with various linear programming solvers
https://docs.rs/lp-solvers/
MIT License
19 stars 9 forks source link

GurobiSolver not working #2

Open luli-git opened 3 years ago

luli-git commented 3 years ago

Hi,

I was trying to use the Gurobi solver instead of the CBC solver. I have installed Gurobi, got a valid license, and changed the correct environment variable path. I was able to use Gurobi in a program written in Julia. However, when I replaced CbcSolver with GurobiSolver in the example code as below, I got the following error:

fn main() {
    solve_integer_problem_with_solver(GurobiSolver::default())
}

thread 'main' panicked at 'Failed to run solver: "gurobi_cl exited with status exit code: 1"', src/main.rs:197:36 stack backtrace: 0: rust_begin_unwind at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5 1: core::panicking::panic_fmt at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14 2: core::option::expect_none_failed at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/option.rs:1329:5 3: core::result::Result<T,E>::expect at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:997:23 4: optimal_representatives::solve_integer_problem_with_solver at ./src/main.rs:197:20 5: optimal_representatives::main at ./src/main.rs:203:5 6: core::ops::function::FnOnce::call_once at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Below are the results I got with RUST_BACKTRACE=full:

thread 'main' panicked at 'Failed to run solver: "gurobi_cl exited with status exit code: 1"', src/main.rs:197:36 stack backtrace: 0: 0x10e1819e4 - std::backtrace_rs::backtrace::libunwind::trace::h0e344f93e1be12b3 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5 1: 0x10e1819e4 - std::backtrace_rs::backtrace::trace_unsynchronized::h547096f273f197d3 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x10e1819e4 - std::sys_common::backtrace::_print_fmt::h46deca35c22bc084 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:67:5 3: 0x10e1819e4 - ::fmt::h80b40bec9b25cdb7 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:46:22 4: 0x10e19e27e - core::fmt::write::h367e10cc391177e1 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/fmt/mod.rs:1092:17 5: 0x10e17f116 - std::io::Write::write_fmt::h69f760cf0ceceb64 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/io/mod.rs:1572:15 6: 0x10e1837a9 - std::sys_common::backtrace::_print::h06c56467d8f0565c at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:49:5 7: 0x10e1837a9 - std::sys_common::backtrace::print::h83e6ec856bd254a6 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:36:9 8: 0x10e1837a9 - std::panicking::default_hook::{{closure}}::h6b461dbc832ae479 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:208:50 9: 0x10e183290 - std::panicking::default_hook::hf6b37b6d4ff1b717 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:225:9 10: 0x10e183f75 - std::panicking::rust_panic_with_hook::hcc0074a2cdf70335 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:591:17 11: 0x10e183a85 - std::panicking::begin_panic_handler::{{closure}}::hafebb92bbb4f046c at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:497:13 12: 0x10e181e48 - std::sys_common::backtrace::__rust_end_short_backtrace::hbd3b6a5769847c0d at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:141:18 13: 0x10e1839ea - rust_begin_unwind at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5 14: 0x10e19c9bf - core::panicking::panic_fmt::h84e4b5f5d5160f07 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14 15: 0x10e19c805 - core::option::expect_none_failed::h5c27880b225cac16 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/option.rs:1329:5 16: 0x10e0f31ca - core::result::Result<T,E>::expect::hc4000b462f37413d at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:997:23 17: 0x10e100cf1 - optimal_representatives::solve_integer_problem_with_solver::h3ca85bea6a732aba at /Users/luli/Developer/optimal_reps/src/main.rs:197:20 18: 0x10e100eda - optimal_representatives::main::hd13d3c9adc559796 at /Users/luli/Developer/optimal_reps/src/main.rs:203:5 19: 0x10e0fe42e - core::ops::function::FnOnce::call_once::h38671d614c4aa91e at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 20: 0x10e0eecb1 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha8759719c946f9a1 at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18 21: 0x10e0f16c4 - std::rt::lang_start::{{closure}}::h1757b4b572bd06f7 at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:66:18 22: 0x10e1842e4 - core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::h3b22ce68aa2879c2 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/ops/function.rs:259:13 23: 0x10e1842e4 - std::panicking::try::do_call::h51a4853c94b1bdea at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:379:40 24: 0x10e1842e4 - std::panicking::try::ha45bc5eab1f103eb at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:343:19 25: 0x10e1842e4 - std::panic::catch_unwind::h191bc002afc126a7 at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panic.rs:431:14 26: 0x10e1842e4 - std::rt::lang_start_internal::h0c37a46739a0311d at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/rt.rs:51:25 27: 0x10e0f169e - std::rt::lang_start::h8b4b51838af7b438 at /Users/luli/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:65:5 28: 0x10e100ef6 - _main

Thank you so much for your help!

lovasoa commented 3 years ago

Is gurobi_cl in your PATH ? Can you call it and successfully solve .lp problems from the commandline ?