Struct argmin::problem::Problem
[−]
[src]
pub struct Problem<'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: T, pub upper_bound: T, pub constraint: &'a Fn(&T) -> bool, }
This struct hold all information that describes the optimization problem.
Fields
cost_function: &'a Fn(&T) -> U
reference to a function which computes the cost/fitness for a given parameter vector
gradient: Option<&'a Fn(&T) -> T>
optional reference to a function which provides the gradient at a given point in parameter space
hessian: Option<&'a Fn(&T) -> V>
optional reference to a function which provides the Hessian at a given point in parameter space
lower_bound: T
lower bound of the parameter vector
upper_bound: T
upper bound of the parameter vector
constraint: &'a Fn(&T) -> bool
(non)linear constraint which is true
if a parameter vector lies within the bounds
Methods
impl<'a, T: ArgminParameter + 'a, U: ArgminCostValue + 'a, V: 'a> Problem<'a, T, U, V>
[src]
fn new(cost_function: &'a Fn(&T) -> U, lower_bound: &T, upper_bound: &T) -> Self
[src]
Create a new Problem
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
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]
Provide the gradient
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]
Provide additional (non) linear constraint.
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 random_param(&self) -> Result<T, Error>
[src]
Create a random parameter vector
The parameter vector satisfies the lower_bound
and upper_bound
.