Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test solving multiple models in parallel #107

Merged
merged 7 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ jobs:
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/$(echo "v${{env.version}}" | tr -d '.')/SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb
sudo apt-get update && sudo apt install -y ./SCIPOptSuite-${{ env.version }}-Linux-ubuntu.deb

- name: Install tarpaulin
run: cargo install cargo-tarpaulin
- name: Run tests
run: cargo tarpaulin --verbose --all --out Xml
- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
version: '0.15.0'
args: '--verbose --all --out Xml'

- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ raw = []
[dependencies]
scip-sys = "0.1.4"
doc-comment = "0.3.3"

[dev-dependencies]
rayon = "1.5.1"
19 changes: 16 additions & 3 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Model<ProblemCreated> {
.set_cons_modifiable(cons, modifiable)
.expect("Failed to set constraint modifiable");
}

/// Informs the SCIP instance that the objective value is always integral and returns the same `Model` instance.
pub fn set_obj_integral(mut self) -> Self {
self.scip
Expand Down Expand Up @@ -1040,11 +1040,11 @@ impl From<ObjSense> for ffi::SCIP_OBJSENSE {

#[cfg(test)]
mod tests {
use crate::status::Status;
use rayon::prelude::*;
use std::fs;
use std::path::Path;

use crate::status::Status;

use super::*;

#[test]
Expand Down Expand Up @@ -1437,4 +1437,17 @@ mod tests {

assert_eq!(model.status(), Status::TimeLimit);
}

#[test]
fn test_thread_safety() {
let statuses = (0..1000)
.into_par_iter()
.map(|_| {
let model = create_model().hide_output().solve();
model.status()
})
.collect::<Vec<_>>();

assert!(statuses.iter().all(|&s| s == Status::Optimal));
}
}
Loading