Logo
Reference manual - version qle_version
Problem_MT Class Reference

Constrained optimization problem. More...

#include <qle/math/problem_mt.hpp>

Public Member Functions

 Problem_MT (const std::vector< QuantLib::ext::shared_ptr< CostFunction > > &costFunctions, Constraint &constraint, const Array &initialValue=Array())
void reset ()
Real value (const Size i, const Array &x)
 call cost function i computation and increment evaluation counter
Array values (const Size i, const Array &x)
 call cost values i computation and increment evaluation counter
void gradient (const Size i, Array &grad_f, const Array &x)
 call cost function i gradient computation and increment
Real valueAndGradient (const Size i, Array &grad_f, const Array &x)
 call cost function i computation and it gradient
Constraintconstraint () const
 Constraint.
Integer availableCostFunctions () const
 number of available independent cost functions
QuantLib::ext::shared_ptr< CostFunction > costFunction (const Size i) const
 Cost function.
const std::vector< QuantLib::ext::shared_ptr< CostFunction > > & costFunctions () const
 Cost funcionts.
void setCurrentValue (const Array &currentValue)
const Array & currentValue () const
 current value of the local minimum
void setFunctionValue (Real functionValue)
Real functionValue () const
 value of cost function
void setGradientNormValue (Real squaredNorm)
Real gradientNormValue () const
 value of cost function gradient norm
Integer functionEvaluation () const
 number of evaluation of cost function
Integer gradientEvaluation () const
 number of evaluation of cost function gradient

Protected Attributes

std::vector< QuantLib::ext::shared_ptr< CostFunction > > costFunctions_
 Unconstrained cost function.
Constraintconstraint_
 Constraint.
Array currentValue_
 current value of the local minimum
Real functionValue_
 function and gradient norm values at the curentValue_ (i.e. the last step)
Real squaredNorm_
std::vector< Integer > functionEvaluation_
 number of evaluation of cost function and its gradient
std::vector< Integer > gradientEvaluation_

Detailed Description

Constrained optimization problem.

Warning
The passed Constraint instances are stored by reference. The user of this class must make sure that they are not destroyed before the Problem instance.

Constructor & Destructor Documentation

◆ Problem_MT()

Problem_MT ( const std::vector< QuantLib::ext::shared_ptr< CostFunction > > & costFunctions,
Constraint & constraint,
const Array & initialValue = Array() )

The requirement is that the cost functions can be evaluated from multiple threads without data races, which can e.g. be done by complete separation of the underlying data. Note that some methods in this class are not thread safe, namely reset, setCurrentValue, setFunctionValue, setGradientNormValue, i.e. those can not be used from several threads in a mt optimizer

Member Function Documentation

◆ reset()

void reset ( )
Warning
it does not reset the current minumum to any initial value