Crates.io | ripped |
lib.rs | ripped |
version | 0.1.0 |
source | src |
created_at | 2023-10-29 16:17:13.671516 |
updated_at | 2023-10-29 16:17:13.671516 |
description | A pure-Rust Interior-Point solver for linear programs |
homepage | |
repository | https://github.com/sebasv/lp |
max_upload_size | |
id | 1017605 |
size | 132,183 |
A pure-Rust Interior Point solver for linear programs with equality and inequality constraints.
The algorithm is heavily based on the MOSEK solver (open-access link) , and the implementation thereof in SciPy.
A linear program is a mathematical optimization problem defined as (using '
as the dot product):
min_x c ' x
st A_eq ' x == b_eq
A_ub ' x <= b_ub
x >= 0
use ripped::prelude::*;
use approx::assert_abs_diff_eq;
use ndarray::array;
let A_ub = array![[-3f64, 1.], [1., 2.]];
let b_ub = array![6., 4.];
let A_eq = array![[1., 1.]];
let b_eq = array![1.];
let c = array![-1., 4.];
let res = Problem::target(&c)
.ub(&A_ub, &b_ub)
.eq(&A_eq, &b_eq)
.build()
.unwrap();
let solver = InteriorPoint::default();
let solution = solver.solve(&problem);
assert_abs_diff_eq!(solution.x, array![1., 0.], epsilon = 1e-6);