resopt 0.3.0

Declarative constrained residual optimization in Rust
Documentation
//! Declarative constrained residual optimization.
//!
//! This crate models problems of the form
//!
//! ```text
//! minimize_x   loss(Ax - b)
//! subject to   linear equalities
//!              linear inequalities
//!              variable bounds
//! ```
//!
//! `resopt` focuses on a compact API for:
//!
//! - building residual optimization problems
//! - validating structure and dimensions
//! - classifying the problem form
//! - solving with an optional backend such as Clarabel
//!
//! # Example
//!
//! ```rust
//! use resopt::{ConstrainedResidualProblemBuilder, Loss, Matrix, SolveStatus};
//!
//! let a = Matrix::from_row_major(
//!     3,
//!     2,
//!     vec![
//!         1.0, 0.0,
//!         0.0, 1.0,
//!         1.0, 1.0,
//!     ],
//! )?;
//!
//! let problem = ConstrainedResidualProblemBuilder::new()
//!     .matrix(a)
//!     .target(vec![1.0, 2.0, 3.0])
//!     .loss(Loss::L2Squared)
//!     .build()?;
//!
//! let result = problem.solve()?;
//!
//! #[cfg(feature = "clarabel")]
//! assert_eq!(result.status(), SolveStatus::Solved);
//! #[cfg(not(feature = "clarabel"))]
//! assert_eq!(result.status(), SolveStatus::NotImplemented);
//! # Ok::<(), resopt::Error>(())
//! ```
//!
//! With the default `clarabel` feature enabled, `Loss::L2Squared` problems can be solved directly.
//! Other loss functions are accepted by the modeling API and return a solver status indicating
//! that backend support is not implemented yet.

pub mod backends;
pub mod core;
pub mod prelude;
pub mod solve;
pub mod utils;

pub use core::{
    Bounds, ConstrainedResidualProblem, ConstrainedResidualProblemBuilder, Error, LinearEqualities,
    LinearInequalities, LinearResidual, Loss, Matrix, ProblemClass, ProblemSummary,
    TikhonovRegularization, Vector,
};
pub use solve::{
    ClarabelOptions, DefaultSolver, ScalingOptions, Solution, SolveDiagnostics, SolveOptions,
    SolveResult, SolveStatus, Solver,
};

#[cfg(feature = "clarabel")]
pub use backends::clarabel::ClarabelSolver;