optimization_engine/lib.rs
1#![deny(missing_docs)]
2//! **Optimization Engine** is a framework for **fast** and **accurate** embedded nonconvex optimization.
3//!
4//! # About Optimization Engine
5//!
6//!
7//! Its core functionality (including all numerical routines) is written in [Rust](https://www.rust-lang.org/).
8//!
9//! **Optimization Engine** can be used on PCs (all OSs are supported) and on embedded devices
10//! (e.g., Raspberry Pi, Atom, Odroid, etc).
11//!
12//! Note that this is the **API documentation** of **Optimization Engine**; to get started,
13//! you should rather check out the [documentation](https://alphaville.github.io/optimization-engine/).
14//!
15//! # Optimization Problems
16//!
17//! Optimization Engine solves optimization problems of the general form
18//!
19//! $$\begin{aligned}
20//! \mathrm{Minimize}\ f(u)
21//! \\\\
22//! u \in U
23//! \\\\
24//! F_1(u) \in C
25//! \\\\
26//! F_2(u) = 0
27//! \end{aligned}$$
28//!
29//! where
30//!
31//! - $u\in\mathbb{R}^{n_u}$ is the decision variable,
32//! - $f:\mathbb{R}^n\to\mathbb{R}$ is a $C^{1,1}$-smooth cost function,
33//! - $U$ is a (not necessarily convex) closed subset of $\mathbb{R}^{n_u}$
34//! on which we can easily compute projections (e.g., a rectangle, a ball,
35//! a second-order cone, a finite set, etc),
36//! - $F_1:\mathbb{R}^{n_u}\to\mathbb{R}^{n_1}$ and $F_2:\mathbb{R}^{n_u} \to\mathbb{R}^{n_2}$
37//! are mappings with smooth partial derivatives, and
38//! - $C\subseteq\mathbb{R}^{n_1}$ is a convex closed set on which we can easily compute projections.
39//!
40
41extern crate num;
42
43/// Exceptions/Errors that may arise while solving a problem
44#[derive(Debug, Clone, Copy, PartialEq, Eq)]
45pub enum SolverError {
46 /// If the gradient or cost function cannot be evaluated
47 Cost,
48 /// Computation failed and NaN/Infinite value was obtained
49 NotFiniteComputation,
50}
51
52/// Result of a function call (status)
53pub type FunctionCallResult = Result<(), SolverError>;
54
55pub mod alm;
56pub mod cholesky_factorizer;
57pub mod constraints;
58pub mod core;
59pub mod lipschitz_estimator;
60pub mod matrix_operations;
61mod numeric;
62
63pub use crate::cholesky_factorizer::{CholeskyError, CholeskyFactorizer};
64pub use crate::core::fbs;
65pub use crate::core::panoc;
66pub use crate::core::{AlgorithmEngine, Optimizer, Problem};
67
68/* Use Jemalloc if the feature `jem` is activated */
69#[cfg(not(target_env = "msvc"))]
70#[cfg(feature = "jem")]
71use jemallocator::Jemalloc;
72
73#[cfg(not(target_env = "msvc"))]
74#[cfg(feature = "jem")]
75#[global_allocator]
76static JEMALLOC_GLOBAL: Jemalloc = Jemalloc;
77
78#[cfg(all(feature = "rp", not(feature = "jem")))]
79#[global_allocator]
80static RPMALLOC_GLOBAL: rpmalloc::RpMalloc = rpmalloc::RpMalloc;
81
82/* ---------------------------------------------------------------------------- */
83/* TESTS */
84/* ---------------------------------------------------------------------------- */
85#[cfg(test)]
86mod mocks;
87
88#[cfg(test)]
89mod tests;