#![deny(missing_docs)]
extern crate num;
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SolverError {
Cost(&'static str),
NotFiniteComputation(&'static str),
ProjectionFailed(&'static str),
LinearAlgebraFailure(&'static str),
InvalidProblemState(&'static str),
}
impl fmt::Display for SolverError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SolverError::Cost(reason) => {
write!(f, "cost or gradient evaluation failed: {}", reason)
}
SolverError::NotFiniteComputation(reason) => {
write!(f, "non-finite computation: {}", reason)
}
SolverError::ProjectionFailed(reason) => write!(f, "projection failed: {}", reason),
SolverError::LinearAlgebraFailure(reason) => {
write!(f, "linear algebra failure: {}", reason)
}
SolverError::InvalidProblemState(reason) => {
write!(f, "invalid internal problem state: {}", reason)
}
}
}
}
impl std::error::Error for SolverError {}
impl From<crate::matrix_operations::MatrixError> for SolverError {
fn from(_: crate::matrix_operations::MatrixError) -> Self {
SolverError::LinearAlgebraFailure("matrix operation failed")
}
}
impl From<crate::cholesky_factorizer::CholeskyError> for SolverError {
fn from(_: crate::cholesky_factorizer::CholeskyError) -> Self {
SolverError::LinearAlgebraFailure("Cholesky factorization or solve failed")
}
}
pub type FunctionCallResult = Result<(), SolverError>;
pub mod alm;
pub mod cholesky_factorizer;
pub mod constraints;
pub mod core;
pub mod lipschitz_estimator;
pub mod matrix_operations;
mod numeric;
pub use crate::cholesky_factorizer::{CholeskyError, CholeskyFactorizer};
pub use crate::core::fbs;
pub use crate::core::panoc;
pub use crate::core::{AlgorithmEngine, Optimizer, Problem};
#[cfg(not(target_env = "msvc"))]
#[cfg(feature = "jem")]
use jemallocator::Jemalloc;
#[cfg(not(target_env = "msvc"))]
#[cfg(feature = "jem")]
#[global_allocator]
static JEMALLOC_GLOBAL: Jemalloc = Jemalloc;
#[cfg(all(feature = "rp", not(feature = "jem")))]
#[global_allocator]
static RPMALLOC_GLOBAL: rpmalloc::RpMalloc = rpmalloc::RpMalloc;
#[cfg(test)]
mod mocks;
#[cfg(test)]
mod tests;