pub struct Solution {
pub status: SolveStatus,
pub x: Vec<f64>,
pub dual: DualVariables,
pub objective: f64,
pub residuals: KktResiduals,
pub iterations: usize,
pub solve_time: Duration,
pub final_rho: f64,
pub rho_updates: usize,
pub polished: bool,
pub diagnostics: Option<ConvergenceDiagnostics>,
pub certificate: Option<Certificate>,
}Expand description
Solver result and diagnostics.
Fields§
§status: SolveStatusTermination status.
x: Vec<f64>Primal decision vector.
dual: DualVariablesConstraint multipliers.
objective: f64Objective value at the returned iterate.
residuals: KktResidualsKKT residuals at the returned iterate.
iterations: usizeNumber of completed ADMM iterations.
solve_time: DurationWall-clock time this solve was charged with: setup plus iteration for
Solver::solve, iteration only for
Workspace::solve (setup was paid at
workspace construction).
final_rho: f64Penalty used for the final iteration.
rho_updates: usizeNumber of adaptive penalty changes. Each change needs the matching reduced factorization: one-shot solves rebuild it, workspace solves reuse a cached one when the penalty was already visited.
polished: boolWhether the returned iterate is the polished one: true only when
the status is SolveStatus::Solved, SolverSettings::polish is
enabled, and the direct active-set solve improved the worst KKT
residual (otherwise the ADMM iterate is kept and this stays false).
diagnostics: Option<ConvergenceDiagnostics>Heuristic hints; present only when the status is not Solved.
certificate: Option<Certificate>Infeasibility proof; present only when the status is
SolveStatus::PrimalInfeasible or SolveStatus::DualInfeasible.
Certificates are normalized to unit infinity norm, reported in the
original data space, and independently auditable with
crate::check_primal_certificate /
crate::check_dual_certificate.
Implementations§
Source§impl Solution
impl Solution
Sourcepub fn warm_start(&self) -> WarmStart
pub fn warm_start(&self) -> WarmStart
Converts this solution into a full warm start for a related solve.
Examples found in repository?
40fn main() -> Result<(), Box<dyn Error>> {
41 let first = portfolio(vec![0.09, 0.08, 0.07, 0.06, 0.05, 0.04])?.solve(None)?;
42 require_solved(&first)?;
43
44 let warm_start = first.warm_start();
45 let second = portfolio(vec![0.07, 0.08, 0.10, 0.05, 0.06, 0.04])?
46 .with_quadratic_turnover(first.x.clone(), 0.4)?
47 .solve(Some(&warm_start))?;
48 require_solved(&second)?;
49
50 let budget: f64 = second.x.iter().sum();
51 let one_way_turnover: f64 = first
52 .x
53 .iter()
54 .zip(&second.x)
55 .map(|(old, new)| (new - old).abs())
56 .sum::<f64>()
57 / 2.0;
58 println!("first weights: {:.6?}", first.x);
59 println!("second weights: {:.6?}", second.x);
60 println!("budget: {budget:.10}");
61 println!("one-way turnover: {one_way_turnover:.6}");
62 println!(
63 "status: {}, iterations: {}, primal residual: {:.3e}, dual residual: {:.3e}",
64 second.status, second.iterations, second.residuals.primal, second.residuals.dual
65 );
66 Ok(())
67}