2 releases

0.0.1 Dec 4, 2021
0.0.0 Dec 4, 2021

#10 in #quadratic

Download history 57/week @ 2024-03-15 58/week @ 2024-03-22 72/week @ 2024-03-29 42/week @ 2024-04-05 50/week @ 2024-04-12 56/week @ 2024-04-19 57/week @ 2024-04-26 56/week @ 2024-05-03 47/week @ 2024-05-10 51/week @ 2024-05-17 59/week @ 2024-05-24 58/week @ 2024-05-31 33/week @ 2024-06-07 48/week @ 2024-06-14 53/week @ 2024-06-21 20/week @ 2024-06-28

162 downloads per month

GPL-2.0 license

42KB
937 lines

QuadProg

Crate Tests

A dense quadratic program solver in pure rust, based on the Goldfarb Idnani algorithm. This implementation is based on a few sources, but drew primarily from quadprog.

Usage

Add this to your Cargo.toml:

[dependencies]
quadprog = "0.0.1"

Then solve using:

quadprog::solve_qp(...)

lib.rs:

Solve dense quadratic programs.

This crate implements the Goldfarb Indiani method[^1] for solving quadratic programs of the form:

    minimize     1/2 x' Q x + c' x
    subject to   A1 x  = b1
                 A2 x <= b2

in pure rust. These are solved via the only exported function [solve_qp] which returns a [Solution] struct.

Examples

If we want to solve

    minimize     1/2 x^2 + 1/2 y^2 + x
    subject to   x + 2 y >= 1

we can do so with the following example:

let mut q = [1., 0., 0., 1.];
let c = [1., 0.];
let a = [-1., -2.];
let b = [-1.];
let sol = solve_qp(&mut q, &c, &a, &b, 0, false).unwrap();
assert_eq!(sol.sol, &[-0.6, 0.8]);

[^1] D. Goldfarb and A. Idnani (1983). A numerically stable dual method for solving strictly convex quadratic programs. Mathematical Programming, 27, 1-33.

No runtime deps