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

Better handling of unexpected plugin behaviors #150

Merged
merged 2 commits into from
Sep 13, 2024
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
21 changes: 0 additions & 21 deletions src/branchrule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,6 @@ mod tests {
use crate::Solving;
use crate::{model::Model, status::Status};

struct PanickingBranchingRule;
impl BranchRule for PanickingBranchingRule {
fn execute(&mut self, _candidates: Vec<BranchingCandidate>) -> BranchingResult {
panic!("Not implemented")
}
}

#[test]
#[should_panic]
fn panicking_branchrule() {
let br = PanickingBranchingRule {};

Model::new()
.hide_output()
.include_default_plugins()
.read_prob("data/test/gen-ip054.mps")
.unwrap()
.include_branch_rule("", "", 100000, 1000, 1., Box::new(br))
.solve();
}

struct FirstChoosingBranchingRule {
pub chosen: Option<BranchingCandidate>,
}
Expand Down
24 changes: 0 additions & 24 deletions src/pricer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,6 @@ mod tests {
ProblemOrSolving, Solving,
};

struct PanickingPricer;

impl Pricer for PanickingPricer {
fn generate_columns(&mut self, _farkas: bool) -> PricerResult {
panic!("Not implemented")
}
}

#[test]
#[should_panic]
fn panicking_pricer() {
let pricer = PanickingPricer {};

let model = crate::model::Model::new()
.hide_output()
.include_default_plugins()
.read_prob("data/test/simple.lp")
.unwrap()
.include_pricer("", "", 9999999, false, Box::new(pricer));

// solve model
model.solve();
}

struct LyingPricer;

impl Pricer for LyingPricer {
Expand Down
7 changes: 5 additions & 2 deletions src/scip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,9 @@ impl ScipPtr {

if pricing_res.state == PricerResultState::FoundColumns {
let n_vars_after = unsafe { ffi::SCIPgetNVars(scip) };
assert!(n_vars_before < n_vars_after);
if n_vars_before >= n_vars_after {
return Retcode::Error.into();
}
}

unsafe { *result = pricing_res.state.into() };
Expand Down Expand Up @@ -845,10 +847,11 @@ impl ScipPtr {
if new_n_sols <= current_n_sols {
let heur_name =
unsafe { CStr::from_ptr(ffi::SCIPheurGetName(heur)).to_str().unwrap() };
panic!(
eprintln!(
"Heuristic {} returned result {:?}, but no solutions were added",
heur_name, heur_res
);
return Retcode::Error.into();
}
}

Expand Down
Loading