pub struct BallInf<'a, T = f64> { /* private fields */ }Expand description
An infinity ball defined as $B_\infty^r = \{x\in\mathbb{R}^n {}:{} \Vert{}x{}\Vert_{\infty} \leq r\}$, where $\Vert{}\cdot{}\Vert_{\infty}$ is the infinity norm. The infinity ball centered at a point $x_c$ is defined as $B_\infty^{x_c,r} = \{x\in\mathbb{R}^n {}:{} \Vert{}x-x_c{}\Vert_{\infty} \leq r\}$.
Implementations§
Source§impl<'a, T: Float> BallInf<'a, T>
impl<'a, T: Float> BallInf<'a, T>
Sourcepub fn new(center: Option<&'a [T]>, radius: T) -> Self
pub fn new(center: Option<&'a [T]>, radius: T) -> Self
Construct a new infinity-norm ball with given center and radius
If no center is given, then it is assumed to be in the origin
§Example
use optimization_engine::constraints::{BallInf, Constraint};
let ball = BallInf::new(None, 1.0);
let mut x = [2.0, -0.2, -3.0];
ball.project(&mut x).unwrap();Trait Implementations§
Source§impl<'a, T: Float> Constraint<T> for BallInf<'a, T>
impl<'a, T: Float> Constraint<T> for BallInf<'a, T>
Source§fn project(&self, x: &mut [T]) -> FunctionCallResult
fn project(&self, x: &mut [T]) -> FunctionCallResult
Computes the projection of a given vector x on the current infinity ball.
The projection of a $v\in\mathbb{R}^{n}$ on $B_\infty^r$ is given by $\Pi_{B_\infty^r}(v) = z$ with
$$ z_i = \begin{cases}v_i,&\text{ if } |z_i| \leq r\\\mathrm{sng}(v_i)r,&\text{ otherwise}\end{cases} $$
for all $i=1,\ldots, n$, where sgn is the sign function.
The projection of $v\in\mathbb{R}^{n}$ on $B_\infty^{x_c,r}$ is given by $\Pi_{B_\infty^r}(v) = z$ with
$$ z_i = \begin{cases}v_i,&\text{ if } |z_i-x_{c, i}| \leq r\\x_{c,i} + \mathrm{sng}(v_i)r,&\text{ otherwise}\end{cases} $$
for all $i=1,\ldots, n$.