pub struct SolverResult {
pub termination: TerminationStatus,
pub primal_status: PrimalStatus,
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 raw_log: Option<String>,
pub solver_name: 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§solutions: Vec<SolutionPoint>§dual: FxHashMap<ConstraintId, f64>§soc_dual: FxHashMap<SocConstraintId, f64>§reduced_costs: FxHashMap<VarId, f64>§best_bound: Option<f64>§gap: Option<f64>§solve_time: Duration§iterations: u64§raw_log: Option<String>§solver_name: 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>
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.
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