pub struct Rectangle<'a, T = f64> { /* private fields */ }Expand description
A rectangle, $R = \{x \in \mathbb{R}^n {}:{} x_{\min} {}\leq{} x {}\leq{} x_{\max}\}$
A set of the form $\{x \in \mathbb{R}^n {}:{} x_{\min} {}\leq{} x {}\leq{} x_{\max}\}$, where $\leq$ is meant in the element-wise sense and either of $x_{\min}$ and $x_{\max}$ can be equal to infinity.
Implementations§
Source§impl<'a, T: Float> Rectangle<'a, T>
impl<'a, T: Float> Rectangle<'a, T>
Sourcepub fn new(xmin: Option<&'a [T]>, xmax: Option<&'a [T]>) -> Self
pub fn new(xmin: Option<&'a [T]>, xmax: Option<&'a [T]>) -> Self
Construct a new rectangle with given $x_{\min}$ and $x_{\max}$
§Arguments
xmin: minimum value ofxxmax: maximum value ofx
§Note
Rectangle does not copy xmin and xmax internally; it only keeps
a reference. You may set one of xmin and xmax to None (but not
both).
§Panics
The method panics if:
- Both
xminandxmaxareNone(useNoConstraintsinstead) - Both
xminandxmaxhave been provided, but they have incompatible dimensions
§Example
use optimization_engine::constraints::{Constraint, Rectangle};
let xmin = [-1.0, 0.0];
let xmax = [1.0, 2.0];
let rectangle = Rectangle::new(Some(&xmin), Some(&xmax));
let mut x = [3.0, -4.0];
rectangle.project(&mut x).unwrap();Trait Implementations§
Source§impl<'a, T: Float> Constraint<T> for Rectangle<'a, T>
impl<'a, T: Float> Constraint<T> for Rectangle<'a, T>
impl<'a, T: Copy> Copy for Rectangle<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for Rectangle<'a, T>
impl<'a, T> RefUnwindSafe for Rectangle<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Rectangle<'a, T>where
T: Sync,
impl<'a, T> Sync for Rectangle<'a, T>where
T: Sync,
impl<'a, T> Unpin for Rectangle<'a, T>
impl<'a, T> UnsafeUnpin for Rectangle<'a, T>
impl<'a, T> UnwindSafe for Rectangle<'a, T>where
T: RefUnwindSafe,
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