pub struct IntegerLinearProgram {
pub ge_ph: Polyhedron,
pub eq_ph: Polyhedron,
pub of: Vec<f64>,
}Expand description
Data structure for an integer linear program (ILP).
Fields§
§ge_ph: PolyhedronPolyhedron with constraints on the form $ A \ge b $.
eq_ph: PolyhedronPolyhedron with constraints on the form $ A = b $.
of: Vec<f64>Objective function.
Implementations§
Source§impl IntegerLinearProgram
impl IntegerLinearProgram
Sourcepub fn solve(&self) -> IntegerSolution
pub fn solve(&self) -> IntegerSolution
Solves a linear program with the revised simplex algorithm and produces an integer solution using the Land-Doig-Dakins algorithm.
§Example:
Solve the linear program $$ \max \quad -4x_1+-5x_2 $$ $$ s.t. \quad x_1+4x_2 \geq 4 $$ $$ \qquad \ 3x_1+2x_2 \geq 6 $$ $$ \qquad \ x_1, x_2 \geq 0$$
use puanrs::solver::IntegerLinearProgram;
use puanrs::polyopt::{Polyhedron, VariableFloat};
use puanrs::linalg::Matrix;
let sol = IntegerLinearProgram {
ge_ph: Polyhedron {
a: Matrix{
val: vec![1.0, 4.0, 3.0, 2.0],
nrows: 2,
ncols: 2
},
b: vec![4.0, 6.0],
variables: vec![ VariableFloat { id:0, bounds: (0.0,f64::MAX) }, VariableFloat { id: 1, bounds: (0.0,f64::MAX) }],
index: vec![Some(0),Some(1)],
},
eq_ph: Default::default(),
of: vec![-4.0, -5.0],
}.solve();
assert_eq!(sol.z, -13);
assert_eq!(sol.x, vec![2, 1]);
assert_eq!(sol.status_code, 5);Trait Implementations§
Source§impl Clone for IntegerLinearProgram
impl Clone for IntegerLinearProgram
Source§impl Default for IntegerLinearProgram
impl Default for IntegerLinearProgram
Source§fn default() -> IntegerLinearProgram
fn default() -> IntegerLinearProgram
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for IntegerLinearProgram
impl RefUnwindSafe for IntegerLinearProgram
impl Send for IntegerLinearProgram
impl Sync for IntegerLinearProgram
impl Unpin for IntegerLinearProgram
impl UnsafeUnpin for IntegerLinearProgram
impl UnwindSafe for IntegerLinearProgram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more