Struct highs::Problem[][src]

pub struct Problem<MATRIX = ColMatrix> { /* fields omitted */ }

A complete optimization problem. Depending on the MATRIX type parameter, the problem will be built constraint by constraint (with ColProblem), or variable by variable (with RowProblem)


impl Problem<ColMatrix>[src]

To use these functions, you need to first add all your constraints, and then add variables one by one using the Row objects.

pub fn add_row<N: Into<f64> + Copy, B: RangeBounds<N>>(
    &mut self,
    bounds: B
) -> Row

Add a row (a constraint) to the problem. The concrete factors are added later, when creating columns.

pub fn add_column<N: Into<f64> + Copy, B: RangeBounds<N>, ITEM: Borrow<(Row, f64)>, I: IntoIterator<Item = ITEM>>(
    &mut self,
    col_factor: f64,
    bounds: B,
    row_factors: I

Add a variable to the problem.

  • col_factor represents the factor in front of the variable in the objective function.
  • bounds represents the maximal and minimal allowed values of the variable.
  • row_factors defines how much this variable weights in each constraint.
use highs::{ColProblem, Sense};
let mut pb = ColProblem::new();
let constraint = pb.add_row(..=5); // adds a constraint that cannot take a value over 5
// add a variable that has a coefficient 2 in the objective function, is >=0, and has a coefficient
// 2 in the constraint
pb.add_column(2., 0.., &[(constraint, 2.)]);

impl Problem<RowMatrix>[src]

Functions to use when first declaring variables, then constraints.

pub fn add_column<N: Into<f64> + Copy, B: RangeBounds<N>>(
    &mut self,
    col_factor: f64,
    bounds: B
) -> Col

add a variable to the problem.

  • col_factor is the coefficient in front of the variable in the objective function.
  • bounds are the maximal and minimal values that the variable can take.

pub fn add_row<N: Into<f64> + Copy, B: RangeBounds<N>, ITEM: Borrow<(Col, f64)>, I: IntoIterator<Item = ITEM>>(
    &mut self,
    bounds: B,
    row_factors: I

Add a constraint to the problem.

  • bounds are the maximal and minimal allowed values for the linear expression in the constraint
  • row_factors are the coefficients in the linear expression expressing the constraint
use highs::*;
let mut pb = RowProblem::new();
// Optimize 3x - 2y with x<=6 and y>=5
let x = pb.add_column(3., ..6);
let y = pb.add_column(-2., 5..);
pb.add_row(2.., &[(x, 3.), (y, 8.)]); // 2 <= x*3 + y*8

impl<MATRIX: Default> Problem<MATRIX> where
    Problem<ColMatrix>: From<Problem<MATRIX>>, 

pub fn num_cols(&self) -> usize[src]

Number of variables in the problem

pub fn num_rows(&self) -> usize[src]

Number of constraints in the problem

pub fn optimise(self, sense: Sense) -> Model[src]

Create a model based on this problem. Don’t solve it yet. If the problem is a RowProblem, it will have to be converted to a ColProblem first, which takes an amount of time proportional to the size of the problem.

pub fn new() -> Self[src]

Create a new problem instance

Trait Implementations

impl<MATRIX: Clone> Clone for Problem<MATRIX>[src]

impl<MATRIX: Debug> Debug for Problem<MATRIX>[src]

impl<MATRIX: Default> Default for Problem<MATRIX>[src]

impl From<Problem<RowMatrix>> for Problem<ColMatrix>[src]

impl<MATRIX: PartialEq> PartialEq<Problem<MATRIX>> for Problem<MATRIX>[src]

impl<MATRIX> StructuralPartialEq for Problem<MATRIX>[src]

Auto Trait Implementations

impl<MATRIX> RefUnwindSafe for Problem<MATRIX> where
    MATRIX: RefUnwindSafe

impl<MATRIX> Send for Problem<MATRIX> where
    MATRIX: Send

impl<MATRIX> Sync for Problem<MATRIX> where
    MATRIX: Sync

impl<MATRIX> Unpin for Problem<MATRIX> where
    MATRIX: Unpin

impl<MATRIX> UnwindSafe for Problem<MATRIX> where
    MATRIX: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.