# Struct argmin::problem::ArgminProblem [−] [src]

```pub struct ArgminProblem<'a, T: ArgminParameter + 'a, U: ArgminCostValue + 'a, V: 'a> {
pub cost_function: &'a Fn(&T) -> U,
pub gradient: Option<&'a Fn(&T) -> T>,
pub hessian: Option<&'a Fn(&T) -> V>,
pub lower_bound: Option<T>,
pub upper_bound: Option<T>,
pub constraint: &'a Fn(&T) -> bool,
pub target_cost: U,
}```

This struct hold all information that describes the optimization problem.

## Fields

reference to a function which computes the cost/fitness for a given parameter vector

optional reference to a function which provides the gradient at a given point in parameter space

optional reference to a function which provides the Hessian at a given point in parameter space

lower bound of the parameter vector

upper bound of the parameter vector

(non)linear constraint which is `true` if a parameter vector lies within the bounds

Target cost function value. The optimization will stop once this value is reached.

## Methods

### `impl<'a, T: ArgminParameter + 'a, U: ArgminCostValue + 'a, V: 'a> ArgminProblem<'a, T, U, V>`[src]

#### `fn new(cost_function: &'a Fn(&T) -> U) -> Self`[src]

Create a new `ArgminProblem` struct.

The field `gradient` is automatically set to `None`, but can be manually set by the `gradient` function. The (non) linear constraint `constraint` is set to a closure which evaluates to `true` everywhere. This can be overwritten with the `constraint` function.

`cost_function`: Reference to a cost function

#### `fn bounds(&mut self, lower_bound: &T, upper_bound: &T) -> &mut Self`[src]

Set lower and upper bounds

`lower_bound`: lower bound for the parameter vector `upper_bound`: upper bound for the parameter vector

#### `fn gradient(&mut self, gradient: &'a Fn(&T) -> T) -> &mut Self`[src]

The function has to have the signature `&Fn(&T) -> T` where `T` is the type of the parameter vector. The function returns the gradient for a given parameter vector.

#### `fn hessian(&mut self, hessian: &'a Fn(&T) -> V) -> &mut Self`[src]

Provide the Hessian

The function has to have the signature `&Fn(&T) -> T` where `T` is the type of the parameter vector. The function returns the gradient for a given parameter vector.

#### `fn constraint(&mut self, constraint: &'a Fn(&T) -> bool) -> &mut Self`[src]

The function has to have the signature `&Fn(&T) -> bool` where `T` is the type of the parameter vector. The function returns `true` if all constraints are satisfied and `false` otherwise.

#### `fn target_cost(&mut self, target_cost: U) -> &mut Self`[src]

Set target cost function value

If the optimization reaches this value, it will be stopped.

#### `fn random_param(&self) -> Result<T, Error>`[src]

Create a random parameter vector

The parameter vector satisfies the `lower_bound` and `upper_bound`.