Skip to main content

cova_solver/
traits.rs

1//! Common traits and types for optimization solvers using argmin framework
2
3use cova_algebra::tensors::DVector;
4
5use crate::SolverResult;
6
7/// Solution information returned by solvers
8#[derive(Debug, Clone)]
9pub struct Solution {
10  /// The optimal solution vector
11  pub x:               DVector<f64>,
12  /// The optimal objective value
13  pub objective_value: f64,
14  /// Number of iterations taken
15  pub iterations:      u64,
16  /// Whether the solver converged
17  pub converged:       bool,
18  /// Termination reason
19  pub termination:     String,
20}
21
22/// Common interface for optimization problems that can be solved with argmin
23pub trait OptimizationProblem {
24  /// Get the problem dimension
25  fn dimension(&self) -> usize;
26
27  /// Solve the optimization problem using argmin
28  fn solve(&self) -> SolverResult<Solution>;
29}