pub struct Simplex<T = f64> { /* private fields */ }Expand description
A simplex with level $\alpha$ is a set of the form $\Delta_\alpha^n = \{x \in \mathbb{R}^n {}:{} x \geq 0, \sum_i x_i = \alpha\}$, where $\alpha$ is a positive constant.
Implementations§
Source§impl<T: Float> Simplex<T>
impl<T: Float> Simplex<T>
Sourcepub fn new(alpha: T) -> Self
pub fn new(alpha: T) -> Self
Construct a new simplex with given (positive) $\alpha$. The user does not need to specify the dimension of the simplex.
§Example
use optimization_engine::constraints::{Constraint, Simplex};
let simplex = Simplex::new(1.0);
let mut x = [0.5, -0.5, 2.0];
simplex.project(&mut x).unwrap();Trait Implementations§
Source§impl<T: Float> Constraint<T> for Simplex<T>
impl<T: Float> Constraint<T> for Simplex<T>
Source§fn project(&self, x: &mut [T]) -> FunctionCallResult
fn project(&self, x: &mut [T]) -> FunctionCallResult
Project onto $\Delta_\alpha^n$ using Condat’s fast projection algorithm.
See: Laurent Condat. Fast Projection onto the Simplex and the $\ell_1$ Ball. Mathematical Programming, Series A, Springer, 2016, 158 (1), pp.575-585. ⟨10.1007/s10107-015-0946-6⟩.
impl<T: Copy> Copy for Simplex<T>
Auto Trait Implementations§
impl<T> Freeze for Simplex<T>where
T: Freeze,
impl<T> RefUnwindSafe for Simplex<T>where
T: RefUnwindSafe,
impl<T> Send for Simplex<T>where
T: Send,
impl<T> Sync for Simplex<T>where
T: Sync,
impl<T> Unpin for Simplex<T>where
T: Unpin,
impl<T> UnsafeUnpin for Simplex<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Simplex<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more