#quadratic #linear-programming #problem #solver #matrix #back-end #qp

simple_qp

Allows formulating Quadratic Programming problems in a symbolic way

4 releases

0.2.2 Oct 4, 2024
0.2.1 Jul 19, 2024
0.2.0 Jul 19, 2024
0.1.0 Jul 7, 2024

#897 in Algorithms

Download history 28/week @ 2024-07-09 185/week @ 2024-07-16 42/week @ 2024-07-23 26/week @ 2024-09-10 10/week @ 2024-09-17 12/week @ 2024-09-24 266/week @ 2024-10-01 59/week @ 2024-10-08 3/week @ 2024-10-15

329 downloads per month

MIT license

42KB
1K SLoC

simple_qp

Rust

simple_qp allows formulating Quadratic Programming (QP) problems in a symbolic way. Define your QP without unreadable matrix initializations.

Available Solver Backends

At the moment, these are the available solver backends:

  • OSQP
  • CLARABEL
  • COIN CBC: restricted to Linear Programming problems

Example Code

use simple_qp::constraint;
use simple_qp::problem_variables::ProblemVariables;
use simple_qp::solver::osqp_solver::OSQPSolver;
use simple_qp::solver::Solver;

fn main() {
    let mut problem = ProblemVariables::default();
    let x = problem.add_variable(Some(85.), None);
    let y = problem.add_variable(Some(4.0), None);

    let objective = (x - 42).square() + (y - 73).square() + (x - y).square();

    let constraints = vec![
        constraint!(50 <= 1.5 * (x / 3 + 2 * y) <= 100),
        constraint!(x - y == 75 + 2 * y),
    ];

    let solver = OSQPSolver::default();
    let res = solver
        .solve(problem, objective, constraints)
        .expect("Solver error");

    let x_solution = res.value(x);
    let y_solution = res.value(y);

    println!("x = {}, y = {}", x_solution, y_solution);
}

Acknowledgment

Thanks FlorianNAdam for the constraint! macro.

Dependencies

~4MB
~85K SLoC