pub struct SolverResult {Show 16 fields
pub termination: TerminationStatus,
pub primal_status: PrimalStatus,
pub dual_status: DualStatus,
pub solutions: Vec<SolutionPoint>,
pub dual: FxHashMap<ConstraintId, f64>,
pub soc_dual: FxHashMap<SocConstraintId, f64>,
pub reduced_costs: FxHashMap<VarId, f64>,
pub best_bound: Option<f64>,
pub gap: Option<f64>,
pub solve_time: Duration,
pub iterations: u64,
pub node_count: Option<u64>,
pub raw_status: Option<Cow<'static, str>>,
pub raw_log: Option<String>,
pub solver_name: Option<Cow<'static, str>>,
pub solver_version: Option<Cow<'static, str>>,
}Expand description
A solver’s final result on a model.
termination expresses why the solver stopped and primal_status says
whether the point in solutions is usable. 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. best_bound and gap are populated by branch-and-bound
backends when available.
Fields§
§termination: TerminationStatus§primal_status: PrimalStatus§dual_status: DualStatus§solutions: Vec<SolutionPoint>§dual: FxHashMap<ConstraintId, f64>§soc_dual: FxHashMap<SocConstraintId, f64>§reduced_costs: FxHashMap<VarId, f64>§best_bound: Option<f64>The best objective bound reported by the backend.
gap: Option<f64>The backend’s relative optimality gap.
solve_time: Duration§iterations: u64A backend-defined aggregate iteration count.
node_count: Option<u64>§raw_status: Option<Cow<'static, str>>A compact native status label or code, distinct from Self::raw_log.
raw_log: Option<String>§solver_name: Option<Cow<'static, str>>§solver_version: Option<Cow<'static, str>>Implementations§
Source§impl SolverResult
impl SolverResult
Sourcepub fn result_count(&self) -> usize
pub fn result_count(&self) -> usize
The number of primal points the solver returned (0 when infeasible or
unsolved).
Sourcepub fn solution(&self, i: usize) -> Option<&SolutionPoint>
pub fn solution(&self, i: usize) -> Option<&SolutionPoint>
The i-th primal point, where index 0 is the best/incumbent.
Sourcepub fn best(&self) -> Option<&SolutionPoint>
pub fn best(&self) -> Option<&SolutionPoint>
The best primal point, or None when no solution was found.
Sourcepub fn has_solution(&self) -> bool
pub fn has_solution(&self) -> bool
Whether a usable primal point is available, regardless of why the solver
stopped. Driven by PrimalStatus, so an incumbent returned at a time
or iteration limit still counts.
Sourcepub fn objective(&self) -> Option<f64>
pub fn objective(&self) -> Option<f64>
The objective value of the best solution, or None when none was found.
Sourcepub fn primal(&self) -> Option<&FxHashMap<VarId, f64>>
pub fn primal(&self) -> Option<&FxHashMap<VarId, f64>>
The best solution’s primal map, or None when no solution was found.
Sourcepub fn value(&self, id: VarId) -> Option<f64>
pub fn value(&self, id: VarId) -> Option<f64>
Look up a primal value by VarId in the best solution.
Sourcepub fn value_of(&self, expr: Expr<'_>) -> Option<f64>
pub fn value_of(&self, expr: Expr<'_>) -> Option<f64>
Evaluate an expression at the best solution.
Sourcepub fn constraint_evaluation(
&self,
model: &Model,
id: ConstraintId,
) -> Option<ConstraintEvaluation>
pub fn constraint_evaluation( &self, model: &Model, id: ConstraintId, ) -> Option<ConstraintEvaluation>
Evaluate an algebraic constraint at the best solution.
The result and model must describe the same solve. Parameter values are
read from model at query time, so do not combine an old result with a
subsequently modified model.
Sourcepub fn constraint_evaluation_at(
&self,
model: &Model,
id: ConstraintId,
solution_index: usize,
) -> Option<ConstraintEvaluation>
pub fn constraint_evaluation_at( &self, model: &Model, id: ConstraintId, solution_index: usize, ) -> Option<ConstraintEvaluation>
Evaluate an algebraic constraint at solution solution_index.
Sourcepub fn soc_evaluation(
&self,
model: &Model,
id: SocConstraintId,
) -> Option<SocEvaluation>
pub fn soc_evaluation( &self, model: &Model, id: SocConstraintId, ) -> Option<SocEvaluation>
Evaluate an explicit second-order-cone constraint at the best solution.
Sourcepub fn soc_evaluation_at(
&self,
model: &Model,
id: SocConstraintId,
solution_index: usize,
) -> Option<SocEvaluation>
pub fn soc_evaluation_at( &self, model: &Model, id: SocConstraintId, solution_index: usize, ) -> Option<SocEvaluation>
Evaluate an explicit second-order-cone constraint at solution
solution_index.
pub fn dual_of(&self, c: ConstraintId) -> Option<f64>
Sourcepub fn soc_dual_of(&self, c: SocConstraintId) -> Option<f64>
pub fn soc_dual_of(&self, c: SocConstraintId) -> Option<f64>
The norm-form bound multiplier of an explicit SOC constraint,
or None when the backend did not compute it.
Sourcepub fn value_of_idx<V, K: Into<IndexKey>>(
&self,
var: &IndexedVar<'_, V>,
key: K,
) -> Option<f64>
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.
Sourcepub fn values_of<'iv, 'a, V>(
&'iv self,
var: &'iv IndexedVar<'a, V>,
) -> impl Iterator<Item = (&'iv IndexKey, f64)> + 'iv
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.
Sourcepub fn report<'a>(&'a self, model: &'a Model) -> ModelReport<'a>
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
impl Clone for SolverResult
Source§fn clone(&self) -> SolverResult
fn clone(&self) -> SolverResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SolverResult
impl Debug for SolverResult
Auto Trait Implementations§
impl Freeze for SolverResult
impl RefUnwindSafe for SolverResult
impl Send for SolverResult
impl Sync for SolverResult
impl Unpin for SolverResult
impl UnsafeUnpin for SolverResult
impl UnwindSafe for SolverResult
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
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> ⓘ
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> ⓘ
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