Skip to content

Instantly share code, notes, and snippets.

@yongqli
Created April 13, 2025 18:12
Show Gist options
  • Select an option

  • Save yongqli/c03f7ffc09c45a8fb8333e9996dd7745 to your computer and use it in GitHub Desktop.

Select an option

Save yongqli/c03f7ffc09c45a8fb8333e9996dd7745 to your computer and use it in GitHub Desktop.
osqp test case
use osqp::{CscMatrix, Problem, Settings};
fn main() {
// Define problem data
let P = &[[4.0]];
let P = CscMatrix::from(P).into_upper_tri();
let q = &[1.0];
let A = &[[1.0]];
let settings = Settings::default().verbose(true);
// This works:
let l = &[-1e9];
let u = &[1e9];
Problem::new(&P, q, A, l, u, &settings)
.expect("failed to setup problem")
.solve()
.x()
.expect("failed to solve problem");
// This does NOT work:
let l = &[-f64::NEG_INFINITY];
let u = &[f64::INFINITY];
Problem::new(&P, q, A, l, u, &settings)
.expect("failed to setup problem")
.solve()
.x()
.expect("failed to solve problem");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment