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 constraints;
57pub mod core;
58pub mod lipschitz_estimator;
59pub mod matrix_operations;
60
61pub use crate::core::fbs;
62pub use crate::core::panoc;
63pub use crate::core::{AlgorithmEngine, Optimizer, Problem};
64
65/* Use Jemalloc if the feature `jem` is activated */
66#[cfg(not(target_env = "msvc"))]
67#[cfg(feature = "jem")]
68use jemallocator::Jemalloc;
69
70#[cfg(not(target_env = "msvc"))]
71#[cfg(feature = "jem")]
72#[global_allocator]
73static JEMALLOC_GLOBAL: Jemalloc = Jemalloc;
74
75#[cfg(all(feature = "rp", not(feature = "jem")))]
76#[global_allocator]
77static RPMALLOC_GLOBAL: rpmalloc::RpMalloc = rpmalloc::RpMalloc;
78
79/* ---------------------------------------------------------------------------- */
80/* TESTS */
81/* ---------------------------------------------------------------------------- */
82#[cfg(test)]
83mod mocks;
84
85#[cfg(test)]
86mod tests;