pub struct SolverResult {Show 17 fields
pub model_id: ModelId,
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 is populated when a global bound is available.
gap is the solver-reported gap, whose convention is backend-specific.
Fields§
§model_id: ModelId§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 raw VarId in the best solution. Raw IDs carry
no model provenance; prefer Self::value_of when possible.
Sourcepub fn value_of(
&self,
expr: Expr<'_>,
) -> Result<Option<f64>, ModelMismatchError>
pub fn value_of( &self, expr: Expr<'_>, ) -> Result<Option<f64>, ModelMismatchError>
Evaluate an expression at the best solution, rejecting expressions from
another model with ModelMismatchError.
§Errors
Returns ModelMismatchError if expr belongs to another model.
Sourcepub fn constraint_evaluation(
&self,
model: &Model,
constraint: ConstraintHandle,
) -> Result<Option<ConstraintEvaluation>, ModelMismatchError>
pub fn constraint_evaluation( &self, model: &Model, constraint: ConstraintHandle, ) -> Result<Option<ConstraintEvaluation>, ModelMismatchError>
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.
§Errors
Returns ModelMismatchError if model or the selected solution point
does not belong to this result’s model.
Sourcepub fn constraint_evaluation_at(
&self,
model: &Model,
constraint: ConstraintHandle,
solution_index: usize,
) -> Result<Option<ConstraintEvaluation>, ModelMismatchError>
pub fn constraint_evaluation_at( &self, model: &Model, constraint: ConstraintHandle, solution_index: usize, ) -> Result<Option<ConstraintEvaluation>, ModelMismatchError>
Evaluate an algebraic constraint at solution solution_index.
§Errors
Returns ModelMismatchError if model or the selected solution point
does not belong to this result’s model.
Sourcepub fn soc_evaluation(
&self,
model: &Model,
constraint: SocConstraintHandle,
) -> Result<Option<SocEvaluation>, ModelMismatchError>
pub fn soc_evaluation( &self, model: &Model, constraint: SocConstraintHandle, ) -> Result<Option<SocEvaluation>, ModelMismatchError>
Evaluate an explicit second-order-cone constraint at the best solution.
§Errors
Returns ModelMismatchError if model or the best solution point
does not belong to this result’s model.
Sourcepub fn soc_evaluation_at(
&self,
model: &Model,
constraint: SocConstraintHandle,
solution_index: usize,
) -> Result<Option<SocEvaluation>, ModelMismatchError>
pub fn soc_evaluation_at( &self, model: &Model, constraint: SocConstraintHandle, solution_index: usize, ) -> Result<Option<SocEvaluation>, ModelMismatchError>
Evaluate an explicit second-order-cone constraint at solution
solution_index.
§Errors
Returns ModelMismatchError if model or the selected solution point
does not belong to this result’s model.
Sourcepub fn dual_of(
&self,
constraint: ConstraintHandle,
) -> Result<Option<f64>, ModelMismatchError>
pub fn dual_of( &self, constraint: ConstraintHandle, ) -> Result<Option<f64>, ModelMismatchError>
Look up an algebraic constraint multiplier, rejecting a handle from a different model.
§Errors
Returns ModelMismatchError if constraint belongs to another model.
Sourcepub fn soc_dual_of(
&self,
constraint: SocConstraintHandle,
) -> Result<Option<f64>, ModelMismatchError>
pub fn soc_dual_of( &self, constraint: SocConstraintHandle, ) -> Result<Option<f64>, ModelMismatchError>
The norm-form bound multiplier of an explicit SOC constraint,
or None when the backend did not compute it.
§Errors
Returns ModelMismatchError if constraint belongs to another model.
Sourcepub fn value_of_idx<V, K: Into<IndexKey>>(
&self,
var: &IndexedVar<'_, V>,
key: K,
) -> Result<Option<f64>, ModelMismatchError>
pub fn value_of_idx<V, K: Into<IndexKey>>( &self, var: &IndexedVar<'_, V>, key: K, ) -> Result<Option<f64>, ModelMismatchError>
Look up the best solution’s primal value for a specific index of an
IndexedVar.
§Errors
Returns ModelMismatchError if var belongs to another model.
Sourcepub fn values_of<'iv, 'a, V>(
&'iv self,
var: &'iv IndexedVar<'a, V>,
) -> Result<impl Iterator<Item = (&'iv IndexKey, f64)> + 'iv, ModelMismatchError>
pub fn values_of<'iv, 'a, V>( &'iv self, var: &'iv IndexedVar<'a, V>, ) -> Result<impl Iterator<Item = (&'iv IndexKey, f64)> + 'iv, ModelMismatchError>
Iterate over the best solution’s primal values for all entries of an
IndexedVar. Yields nothing when no solution was found.
§Errors
Returns ModelMismatchError if var or the best solution point does
not belong to this result’s model.
Sourcepub fn report<'a>(
&'a self,
model: &'a Model,
) -> Result<ModelReport<'a>, ModelMismatchError>
pub fn report<'a>( &'a self, model: &'a Model, ) -> Result<ModelReport<'a>, ModelMismatchError>
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.
§Errors
Returns ModelMismatchError if model or the best solution point
does not belong to this result’s model.
Trait Implementations§
Source§impl Clone for SolverResult
impl Clone for SolverResult
Source§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