Skip to main content

SolverResult

Struct SolverResult 

Source
pub struct SolverResult {
    pub status: SolverStatus,
    pub solutions: Vec<SolutionPoint>,
    pub dual: FxHashMap<ConstraintId, f64>,
    pub reduced_costs: FxHashMap<VarId, f64>,
    pub solve_time: Duration,
    pub iterations: u64,
    pub raw_log: Option<String>,
    pub solver_name: Option<Cow<'static, str>>,
}
Expand description

A solver’s final result on a model.

Primal points are held in solutions (index 0 is the best/incumbent, empty when no solution was found). dual and reduced_costs apply to the best continuous point and are sparse maps, so a solver that does not return duals (e.g. MILP) can simply leave them empty.

Fields§

§status: SolverStatus§solutions: Vec<SolutionPoint>§dual: FxHashMap<ConstraintId, f64>§reduced_costs: FxHashMap<VarId, f64>§solve_time: Duration§iterations: u64§raw_log: Option<String>§solver_name: Option<Cow<'static, str>>

Implementations§

Source§

impl SolverResult

Source

pub fn result_count(&self) -> usize

The number of primal points the solver returned (0 when infeasible or unsolved).

Source

pub fn solution(&self, i: usize) -> Option<&SolutionPoint>

The i-th primal point, where index 0 is the best/incumbent.

Source

pub fn best(&self) -> Option<&SolutionPoint>

The best primal point, or None when no solution was found.

Source

pub fn objective(&self) -> Option<f64>

The objective value of the best solution, or None when none was found.

Source

pub fn primal(&self) -> Option<&FxHashMap<VarId, f64>>

The best solution’s primal map, or None when no solution was found.

Source

pub fn value(&self, id: VarId) -> Option<f64>

Look up a primal value by VarId in the best solution.

Source

pub fn value_of(&self, expr: Expr<'_>) -> Option<f64>

Look up the best solution’s primal value for an Expr that points at a Var node. Returns None for any expression that is not a single variable.

Source

pub fn dual_of(&self, c: ConstraintId) -> Option<f64>

Source

pub fn value_of_idx<V, K: Into<IndexKey>>( &self, var: &IndexedVar<'_, V>, key: K, ) -> Option<f64>

Look up the best solution’s primal value for a specific index of an IndexedVar.

Source

pub fn values_of<'iv, 'a, V>( &'iv self, var: &'iv IndexedVar<'a, V>, ) -> impl Iterator<Item = (&'iv IndexKey, f64)> + 'iv

Iterate over the best solution’s primal values for all entries of an IndexedVar. Yields nothing when no solution was found.

Source

pub fn report<'a>(&'a self, model: &'a Model) -> ModelReport<'a>

A human-readable, model-aware summary of this result.

It lists the solver, model kind and sense, status, objective and work counters, then every variable’s value (with its reduced cost when the solver returned duals) and every constraint’s dual.

Trait Implementations§

Source§

impl Clone for SolverResult

Source§

fn clone(&self) -> SolverResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SolverResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SolverResult

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.