pub struct CostModel { /* private fields */ }Expand description
A problem’s cost, ready to evaluate.
Implementations§
Source§impl CostModel
impl CostModel
Sourcepub fn with_threads(self, threads: usize) -> Result<Self>
pub fn with_threads(self, threads: usize) -> Result<Self>
Evaluate on a pool of threads threads instead of the default one. No effect without the parallel
feature or on wasm32.
Sourcepub fn eval_generic<T: Scalar>(
&self,
x: &[T],
grad: bool,
) -> Result<(T, T, T, Option<Vec<T>>)>
pub fn eval_generic<T: Scalar>( &self, x: &[T], grad: bool, ) -> Result<(T, T, T, Option<Vec<T>>)>
(cost, fidelity, penalty, gradient of the cost) over any scalar type; the gradient only when grad.
Sourcepub fn value_and_gradient(&self, x: &[f64]) -> Result<(Eval, Vec<f64>)>
pub fn value_and_gradient(&self, x: &[f64]) -> Result<(Eval, Vec<f64>)>
The cost and its gradient at x.
Sourcepub fn hvp(&self, x: &[f64], v: &[f64]) -> Result<Vec<f64>>
pub fn hvp(&self, x: &[f64], v: &[f64]) -> Result<Vec<f64>>
The Hessian of the cost at x applied to v, exactly: the reverse pass over dual numbers x + ε·v.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CostModel
impl !RefUnwindSafe for CostModel
impl !UnwindSafe for CostModel
impl Forget for CostModel
impl Move for CostModel
impl Send for CostModel
impl Sync for CostModel
impl Unpin for CostModel
impl UnsafeUnpin for CostModel
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SendAlias 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.