KardinalAI / coin_cbc

Rust bindings to the CoinOR CBC MILP Solveur using the C API.
MIT License
16 stars 14 forks source link

Add a test for #9 #12

Closed lovasoa closed 3 years ago

lovasoa commented 3 years ago

This adds a test for #9. You should see the reproduction on the CI run.

TeXitoi commented 3 years ago

I have similar errors without this added test.

lovasoa commented 3 years ago

What do you mean ? Do you have errors running cargo test on master ? I don't.

TeXitoi commented 3 years ago

I do

TeXitoi commented 3 years ago

Also, I don't have the same result with the multithread test

TeXitoi commented 3 years ago

like 1/10 it fails

lovasoa commented 3 years ago

Running

 S=0; F=0; for i in {1..100}; do cargo test; if [ $? == 0 ]; then let S+=1; else let F+=1; fi; done; echo "Successes: $S"; echo "Failures: $F"

I get

Successes: 100
Failures: 0

Both on Linux and MacOS

TeXitoi commented 3 years ago

I don't have the same lib as you I suppose, I have the debian stable one.

i=0; while cargo test; do i=$((i+1)); done; echo $i

gives between 0 and 11 depending on the case.

lovasoa commented 3 years ago

I have the latest one in ubuntu: 2.10.5. Debian stable has 2.9.9 : https://packages.debian.org/buster/coinor-libcbc-dev It probably has bugs that have been fixed in more recent versions.

lovasoa commented 3 years ago

If the bug is a memory corruption bug, you may get debian to issue a security update on stable.

TeXitoi commented 3 years ago

I clearly need the lock for the raw::Model::new

lovasoa commented 3 years ago

Ok, let's add it then

TeXitoi commented 3 years ago

I also don't have the same results on the tests, but I don't see what we can do for that

TeXitoi commented 3 years ago

With the lock on new, this test pass here.

TeXitoi commented 3 years ago
+                        // Solve an empty problem
+                        let mut m = Model::new();
+                        m.load_problem(1, 0, &[0, 0], &[], &[], None, None, None, None, None)
;
+                        m.solve();
+                        assert_eq!(Status::Finished, m.status());
+                        assert_eq!(SecondaryStatus::HasSolution, m.secondary_status());
+                        assert!((m.col_solution()[0]).abs() < 1e-6);
TeXitoi commented 3 years ago

I'll open a PR within a few minutes for my problems.

TeXitoi commented 3 years ago

https://github.com/KardinalAI/coin_cbc/pull/13

TeXitoi commented 3 years ago

So, as this test pass on my coin version, can we say that's a coin bug and close this?

lovasoa commented 3 years ago

Yes, this is a bug in cbc. I reported it as https://github.com/coin-or/Cbc/issues/367