QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Problem Class Reference

Constrained optimization problem. More...

#include <problem.hpp>

+ Collaboration diagram for Problem:

Public Member Functions

 Problem (CostFunction &costFunction, Constraint &constraint, Array initialValue=Array())
 default constructor More...
 
void reset ()
 
Real value (const Array &x)
 call cost function computation and increment evaluation counter More...
 
Array values (const Array &x)
 call cost values computation and increment evaluation counter More...
 
void gradient (Array &grad_f, const Array &x)
 call cost function gradient computation and increment More...
 
Real valueAndGradient (Array &grad_f, const Array &x)
 call cost function computation and it gradient More...
 
Constraintconstraint () const
 Constraint. More...
 
CostFunctioncostFunction () const
 Cost function. More...
 
void setCurrentValue (const Array &currentValue)
 
const ArraycurrentValue () const
 current value of the local minimum More...
 
void setFunctionValue (Real functionValue)
 
Real functionValue () const
 value of cost function More...
 
void setGradientNormValue (Real squaredNorm)
 
Real gradientNormValue () const
 value of cost function gradient norm More...
 
Integer functionEvaluation () const
 number of evaluation of cost function More...
 
Integer gradientEvaluation () const
 number of evaluation of cost function gradient More...
 

Protected Attributes

CostFunctioncostFunction_
 Unconstrained cost function. More...
 
Constraintconstraint_
 Constraint. More...
 
Array currentValue_
 current value of the local minimum More...
 
Real functionValue_
 function and gradient norm values at the currentValue_ (i.e. the last step) More...
 
Real squaredNorm_
 
Integer functionEvaluation_
 number of evaluation of cost function and its gradient More...
 
Integer gradientEvaluation_
 

Detailed Description

Constrained optimization problem.

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

Definition at line 42 of file problem.hpp.

Constructor & Destructor Documentation

◆ Problem()

Problem ( CostFunction costFunction,
Constraint constraint,
Array  initialValue = Array() 
)

default constructor

Definition at line 45 of file problem.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ reset()

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

Definition at line 139 of file problem.hpp.

+ Here is the caller graph for this function:

◆ value()

Real value ( const Array x)

call cost function computation and increment evaluation counter

Examples
GlobalOptimizer.cpp.

Definition at line 116 of file problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ values()

Array values ( const Array x)

call cost values computation and increment evaluation counter

Definition at line 121 of file problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gradient()

void gradient ( Array grad_f,
const Array x 
)

call cost function gradient computation and increment

Definition at line 126 of file problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ valueAndGradient()

Real valueAndGradient ( Array grad_f,
const Array x 
)

call cost function computation and it gradient

Definition at line 132 of file problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constraint()

Constraint & constraint ( ) const

Constraint.

Definition at line 71 of file problem.hpp.

+ Here is the caller graph for this function:

◆ costFunction()

CostFunction & costFunction ( ) const

Cost function.

Definition at line 74 of file problem.hpp.

+ Here is the caller graph for this function:

◆ setCurrentValue()

void setCurrentValue ( const Array currentValue)

Definition at line 76 of file problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentValue()

const Array & currentValue ( ) const

current value of the local minimum

Examples
GlobalOptimizer.cpp.

Definition at line 81 of file problem.hpp.

+ Here is the caller graph for this function:

◆ setFunctionValue()

void setFunctionValue ( Real  functionValue)

Definition at line 83 of file problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ functionValue()

Real functionValue ( ) const

value of cost function

Definition at line 88 of file problem.hpp.

+ Here is the caller graph for this function:

◆ setGradientNormValue()

void setGradientNormValue ( Real  squaredNorm)

Definition at line 90 of file problem.hpp.

+ Here is the caller graph for this function:

◆ gradientNormValue()

Real gradientNormValue ( ) const

value of cost function gradient norm

Definition at line 94 of file problem.hpp.

+ Here is the caller graph for this function:

◆ functionEvaluation()

Integer functionEvaluation ( ) const

number of evaluation of cost function

Definition at line 97 of file problem.hpp.

+ Here is the caller graph for this function:

◆ gradientEvaluation()

Integer gradientEvaluation ( ) const

number of evaluation of cost function gradient

Definition at line 100 of file problem.hpp.

Member Data Documentation

◆ costFunction_

CostFunction& costFunction_
protected

Unconstrained cost function.

Definition at line 104 of file problem.hpp.

◆ constraint_

Constraint& constraint_
protected

Constraint.

Definition at line 106 of file problem.hpp.

◆ currentValue_

Array currentValue_
protected

current value of the local minimum

Definition at line 108 of file problem.hpp.

◆ functionValue_

Real functionValue_
protected

function and gradient norm values at the currentValue_ (i.e. the last step)

Definition at line 110 of file problem.hpp.

◆ squaredNorm_

Real squaredNorm_
protected

Definition at line 110 of file problem.hpp.

◆ functionEvaluation_

Integer functionEvaluation_
protected

number of evaluation of cost function and its gradient

Definition at line 112 of file problem.hpp.

◆ gradientEvaluation_

Integer gradientEvaluation_
protected

Definition at line 112 of file problem.hpp.