Skip to main content

TestProblem

Struct TestProblem 

Source
pub struct TestProblem {}
Expand description

Pseudo problem useful for testing

Implements CostFunction, Operator, Gradient, Jacobian, Hessian, and [Anneal].

Implementations§

Source§

impl TestProblem

Source

pub fn new() -> Self

Create an instance of TestProblem.

§Example
use argmin::core::test_utils::TestProblem;

let problem = TestProblem::new();

Trait Implementations§

Source§

impl Clone for TestProblem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TestProblem

Source§

impl CostFunction for TestProblem

Source§

fn cost(&self, _p: &Self::Param) -> Result<Self::Output, Error>

Returns 1.0f64.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::CostFunction;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.cost(&param)?;
Source§

type Param = Vec<f64>

Type of the parameter vector
Source§

type Output = f64

Type of the return value of the cost function
Source§

fn bulk_cost<P>(&self, params: &[P]) -> Result<Vec<Self::Output>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Output: SendAlias, Self: SyncAlias,

Compute cost in bulk. If the rayon feature is enabled, multiple calls to cost will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
Source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to cost when using bulk_cost. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to cost will be executed sequentially independent of how parallelize is set.
Source§

impl Debug for TestProblem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TestProblem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for TestProblem

Source§

impl Gradient for TestProblem

Source§

fn gradient(&self, p: &Self::Param) -> Result<Self::Param, Error>

Returns a clone of parameter p.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Gradient;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.gradient(&param)?;
Source§

type Param = Vec<f64>

Type of the parameter vector
Source§

type Gradient = Vec<f64>

Type of the gradient
Source§

fn bulk_gradient<P>(&self, params: &[P]) -> Result<Vec<Self::Gradient>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Gradient: SendAlias, Self: SyncAlias,

Compute gradient in bulk. If the rayon feature is enabled, multiple calls to gradient will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
Source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to gradient when using bulk_gradient. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to gradient will be executed sequentially independent of how parallelize is set.
Source§

impl Hash for TestProblem

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Hessian for TestProblem

Source§

fn hessian(&self, p: &Self::Param) -> Result<Self::Hessian, Error>

Returns vec![p, p].

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Hessian;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.hessian(&param)?;
Source§

type Param = Vec<f64>

Type of the parameter vector
Source§

type Hessian = Vec<Vec<f64>>

Type of the Hessian
Source§

fn bulk_hessian<P>(&self, params: &[P]) -> Result<Vec<Self::Hessian>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Hessian: SendAlias, Self: SyncAlias,

Compute hessian in bulk. If the rayon feature is enabled, multiple calls to hessian will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
Source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to hessian when using bulk_hessian. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to hessian will be executed sequentially independent of how parallelize is set.
Source§

impl Jacobian for TestProblem

Source§

fn jacobian(&self, p: &Self::Param) -> Result<Self::Jacobian, Error>

Returns vec![p, p].

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Jacobian;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.jacobian(&param)?;
Source§

type Param = Vec<f64>

Type of the parameter vector
Source§

type Jacobian = Vec<Vec<f64>>

Type of the Jacobian
Source§

fn bulk_jacobian<P>(&self, params: &[P]) -> Result<Vec<Self::Jacobian>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Jacobian: SendAlias, Self: SyncAlias,

Compute jacobian in bulk. If the rayon feature is enabled, multiple calls to jacobian will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
Source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to jacobian when using bulk_jacobian. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to jacobian will be executed sequentially independent of how parallelize is set.
Source§

impl Operator for TestProblem

Source§

fn apply(&self, p: &Self::Param) -> Result<Self::Output, Error>

Returns a clone of parameter p.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Operator;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.apply(&param)?;
Source§

type Param = Vec<f64>

Type of the parameter vector
Source§

type Output = Vec<f64>

Type of the return value of the operator
Source§

fn bulk_apply<P>(&self, params: &[P]) -> Result<Vec<Self::Output>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Output: SendAlias, Self: SyncAlias,

Compute apply in bulk. If the rayon feature is enabled, multiple calls to apply will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
Source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to apply when using bulk_apply. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to apply will be executed sequentially independent of how parallelize is set.
Source§

impl PartialEq for TestProblem

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TestProblem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SendAlias for T

Source§

impl<T> SyncAlias for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V