2 releases

0.0.1 Dec 4, 2021
0.0.0 Dec 4, 2021

#11 in #quadratic

Download history 49/week @ 2024-07-20 51/week @ 2024-07-27 36/week @ 2024-08-03 42/week @ 2024-08-10 38/week @ 2024-08-17 29/week @ 2024-08-24 31/week @ 2024-08-31 38/week @ 2024-09-07 33/week @ 2024-09-14 72/week @ 2024-09-21 39/week @ 2024-09-28 9/week @ 2024-10-05 24/week @ 2024-10-12 28/week @ 2024-10-19 29/week @ 2024-10-26 29/week @ 2024-11-02

110 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