Skip to content

Commit

Permalink
fixes #127
Browse files Browse the repository at this point in the history
  • Loading branch information
goulart-paul committed Nov 26, 2024
1 parent 7036899 commit 13baf43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/solver/implementations/default/presolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ where
cones_new.push(SupportedConeT::NonnegativeConeT(nkeep));
}
} else {
//NB: take() is lazy, so must consume this block
//to force keep_iter to advance to the next cone
markers.last(); // skip this cone
cones_new.push(cone.clone());
}
}
Expand Down
19 changes: 19 additions & 0 deletions tests/presolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ fn test_presolve_single_unbounded() {
assert_eq!(solver.solution.s[3], get_infinity());
}

#[test]
fn test_presolve_single_unbounded_2() {
// tests against https://github.com/oxfordcontrol/Clarabel.rs/issues/127
let (P, c, A, mut b, _) = presolve_test_data();

b[4] = 1e30_f64;

let cones = vec![ZeroConeT(2), NonnegativeConeT(4)];

let settings = DefaultSettings::default();

let mut solver = DefaultSolver::new(&P, &c, &A, &b, &cones, settings);

solver.solve();

assert_eq!(solver.solution.status, SolverStatus::Solved);
assert_eq!(solver.variables.z.len(), 5);
}

#[test]
fn test_presolve_completely_redundant_cone() {
let (P, c, A, mut b, cones) = presolve_test_data();
Expand Down

0 comments on commit 13baf43

Please sign in to comment.