1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::;
/// Trait for optimization solvers.
///
/// Any struct implementing this trait can solve a [`Model`] and produce a [`Solution`].
/// This trait provides a consistent interface across different solver implementations,
/// such as simplex, interior point, branch-and-bound, or lexicographic solvers.
///
/// ```rust
/// # use cnvx_core::{Model, Solver, SolveError, Solution};
/// # struct DummySolver {}
/// #
/// # impl Solver<'_> for DummySolver {
/// # fn new(model: &Model) -> Self { DummySolver {} }
/// # fn solve(&mut self) -> Result<Solution, SolveError> {
/// # Err(SolveError::Unsupported("DummySolver does not implement solving".to_string()))
/// # }
/// # fn get_objective_value(&self) -> f64 { 0.0 }
/// # fn get_solution(&self) -> Vec<f64> { vec![] }
/// # }
/// let mut model = Model::new();
/// // ... build model variables, constraints, objective ...
///
/// let mut solver = DummySolver::new(&model);
/// let result: Result<_, SolveError> = solver.solve();
/// match result {
/// Ok(solution) => println!("Optimal solution: {}", solution.objective_value.unwrap_or(0.0)),
/// Err(e) => println!("Solver error: {}", e),
/// }
/// ```
///
/// Generic over:
/// - `S`: solver state type