pub struct Problem<MATRIX = ColMatrix> { /* private fields */ }
Expand description

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)

Implementations

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

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

Add a continuous 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.)]);

Same as add_column, but forces the solution to contain an integer value for this variable.

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 an integer variable that has a coefficient 2 in the objective function, is >=0, and has a coefficient
// 2 in the constraint
pb.add_integer_column(2., 0.., &[(constraint, 2.)]);

Same as add_column, but lets you define whether the new variable should be integral or continuous.

Functions to use when first declaring variables, then constraints.

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.

Same as add_column, but forces the solution to contain an integer value for this variable.

Same as add_column, but lets you define whether the new variable should be integral or continuous.

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

Number of variables in the problem

Number of constraints in the problem

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. If the problem is invalid (according to HiGHS), this function will panic.

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.

Create a new problem instance

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.