pub struct SolverOrchestrator { /* private fields */ }Expand description
High-level solver facade that combines routing with execution.
Owns a SolverRouter and delegates to the appropriate solver backend.
Provides a solve_with_fallback method that
automatically retries with progressively more robust (but slower)
algorithms when the first choice fails.
§Example
use ruvector_solver::router::{SolverOrchestrator, RouterConfig};
use ruvector_solver::types::{ComputeBudget, CsrMatrix, QueryType};
let orchestrator = SolverOrchestrator::new(RouterConfig::default());
let matrix = CsrMatrix::<f64>::from_coo(3, 3, vec![
(0, 0, 2.0), (0, 1, -0.5),
(1, 0, -0.5), (1, 1, 2.0), (1, 2, -0.5),
(2, 1, -0.5), (2, 2, 2.0),
]);
let rhs = vec![1.0, 0.0, 1.0];
let budget = ComputeBudget::default();
let result = orchestrator
.solve(&matrix, &rhs, QueryType::LinearSystem, &budget)
.unwrap();
assert!(result.residual_norm < 1e-6);Implementations§
Source§impl SolverOrchestrator
impl SolverOrchestrator
Sourcepub fn new(config: RouterConfig) -> Self
pub fn new(config: RouterConfig) -> Self
Create a new orchestrator with the provided routing configuration.
Sourcepub fn router(&self) -> &SolverRouter
pub fn router(&self) -> &SolverRouter
Return a reference to the inner router.
Sourcepub fn solve(
&self,
matrix: &CsrMatrix<f64>,
rhs: &[f64],
query: QueryType,
budget: &ComputeBudget,
) -> Result<SolverResult, SolverError>
pub fn solve( &self, matrix: &CsrMatrix<f64>, rhs: &[f64], query: QueryType, budget: &ComputeBudget, ) -> Result<SolverResult, SolverError>
Auto-select the best algorithm and solve Ax = b.
Analyses the sparsity profile of matrix, routes to the best
algorithm via SolverRouter::select_algorithm, and dispatches.
§Errors
Returns SolverError if the selected solver fails (e.g.
non-convergence, dimension mismatch, numerical instability).
Sourcepub fn solve_with_fallback(
&self,
matrix: &CsrMatrix<f64>,
rhs: &[f64],
query: QueryType,
budget: &ComputeBudget,
) -> Result<SolverResult, SolverError>
pub fn solve_with_fallback( &self, matrix: &CsrMatrix<f64>, rhs: &[f64], query: QueryType, budget: &ComputeBudget, ) -> Result<SolverResult, SolverError>
Solve with a deterministic fallback chain.
Tries the routed algorithm first. On failure, falls back through:
- Selected algorithm (from routing)
- CG (robust iterative)
- Dense (direct, always works for small systems)
Each step is only attempted if the previous one returned an error.
§Errors
Returns the error from the last fallback attempt if all fail.
Sourcepub fn estimate_complexity(
&self,
matrix: &CsrMatrix<f64>,
query: &QueryType,
) -> ComplexityEstimate
pub fn estimate_complexity( &self, matrix: &CsrMatrix<f64>, query: &QueryType, ) -> ComplexityEstimate
Estimate the computational complexity of solving with the routed algorithm, without actually solving.
Useful for admission control, cost estimation, or deciding whether to batch multiple queries.
Sourcepub fn analyze_sparsity(matrix: &CsrMatrix<f64>) -> SparsityProfile
pub fn analyze_sparsity(matrix: &CsrMatrix<f64>) -> SparsityProfile
Analyse the sparsity profile of a CSR matrix.
Performs a single O(nnz) pass over the matrix to compute structural and numerical properties used by the router. This is intentionally cheap so it can be called on every solve request.
Trait Implementations§
Source§impl Clone for SolverOrchestrator
impl Clone for SolverOrchestrator
Source§fn clone(&self) -> SolverOrchestrator
fn clone(&self) -> SolverOrchestrator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more