pub struct MinimaxProblem {
pub funcs: Vec<Box<dyn Fn(&ArrayView1<'_, f64>) -> f64 + Send + Sync>>,
}Expand description
A minimax problem: minimize the maximum over k functions.
Represents:
min_x max_{i=0..k-1} f_i(x)§Example
use scirs2_optimize::robust::minimax::MinimaxProblem;
use scirs2_core::ndarray::ArrayView1;
// max(f0, f1) where f0(x)=x[0]+1, f1(x)=-x[0]+2
let problem = MinimaxProblem::new(vec![
Box::new(|x: &ArrayView1<f64>| x[0] + 1.0),
Box::new(|x: &ArrayView1<f64>| -x[0] + 2.0),
]);Fields§
§funcs: Vec<Box<dyn Fn(&ArrayView1<'_, f64>) -> f64 + Send + Sync>>The functions f_i(x) being maximized.
Implementations§
Source§impl MinimaxProblem
impl MinimaxProblem
Sourcepub fn new(
funcs: Vec<Box<dyn Fn(&ArrayView1<'_, f64>) -> f64 + Send + Sync>>,
) -> Self
pub fn new( funcs: Vec<Box<dyn Fn(&ArrayView1<'_, f64>) -> f64 + Send + Sync>>, ) -> Self
Create a new minimax problem from a collection of functions.
Sourcepub fn eval_max(&self, x: &ArrayView1<'_, f64>) -> f64
pub fn eval_max(&self, x: &ArrayView1<'_, f64>) -> f64
Evaluate max_i f_i(x).
Sourcepub fn eval_all(&self, x: &ArrayView1<'_, f64>) -> Vec<f64>
pub fn eval_all(&self, x: &ArrayView1<'_, f64>) -> Vec<f64>
Evaluate all function values f_i(x).
Sourcepub fn argmax(&self, x: &ArrayView1<'_, f64>) -> usize
pub fn argmax(&self, x: &ArrayView1<'_, f64>) -> usize
Return the index of the maximizing function at x.
Auto Trait Implementations§
impl Freeze for MinimaxProblem
impl !RefUnwindSafe for MinimaxProblem
impl Send for MinimaxProblem
impl Sync for MinimaxProblem
impl Unpin for MinimaxProblem
impl UnsafeUnpin for MinimaxProblem
impl !UnwindSafe for MinimaxProblem
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.