Purple::ConjugateGradient Class Reference

Inheritance diagram for Purple::ConjugateGradient:

Purple::OptimizationAlgorithm List of all members.

Public Types

 PolakRibiere
 FletcherReeves
 GoldenSection
 BrentMethod
enum  SearchDirectionMethod { PolakRibiere, FletcherReeves }
enum  OptimalStepSizeMethod { GoldenSection, BrentMethod }

Public Member Functions

 ConjugateGradient (ObjectiveFunction *)
 ConjugateGradient (void)
virtual ~ConjugateGradient (void)
SearchDirectionMethod getSearchDirectionMethod (void)
OptimalStepSizeMethod getOptimalStepSizeMethod (void)
Vector< double > getInitialArgument (void)
double getGradientNormGoal (void)
int getMaximumNumberOfIterations (void)
int getShowPeriod (void)
double getFirstStepSize (void)
double getOptimalStepSizeTolerance (void)
double getWarningStepSize (void)
void setSearchDirectionMethod (SearchDirectionMethod)
void setOptimalStepSizeMethod (OptimalStepSizeMethod)
void setFirstStepSize (double)
void setOptimalStepSizeTolerance (double)
void setInitialArgument (Vector< double >)
void setGradientNormGoal (double)
void setMaximumNumberOfIterations (int)
void setShowPeriod (int)
void setWarningStepSize (double)
Vector< double > getMinimalArgument (void)
void print (void)
void load (char *)
void save (char *)
void saveOptimizationHistory (char *)

Private Member Functions

double getPolakRibiereParameter (Vector< double >, Vector< double >)
double getFletcherReevesParameter (Vector< double >, Vector< double >)
Vector< double > getFletcherReevesSearchDirection (Vector< double >, Vector< double >, Vector< double >)
Vector< double > getPolakRibiereSearchDirection (Vector< double >, Vector< double >, Vector< double >)
double getGoldenSectionOptimalStepSize (double, double, Vector< double >, Vector< double >)
double getBrentMethodOptimalStepSize (double, double, Vector< double >, Vector< double >)
double getMinimum (Vector< double >)
double getMaximum (Vector< double >)

Private Attributes

Vector< double > initialArgument
double gradientNormGoal
int maximumNumberOfIterations
int showPeriod
double firstStepSize
double optimalStepSizeTolerance
double warningStepSize
Vector< double > evaluationHistory
Vector< double > gradientNormHistory
SearchDirectionMethod searchDirectionMethod
OptimalStepSizeMethod optimalStepSizeMethod

Detailed Description

This concrete class represents a conjugate gradient optimization algorithm for an objective function.

See also:
ObjectiveFunction.

OptimizationAlgorithm.

Definition at line 28 of file ConjugateGradient.h.


Member Enumeration Documentation

enum Purple::ConjugateGradient::SearchDirectionMethod

Enumeration of the available optimization operators for the search direction.

Enumerator:
PolakRibiere 
FletcherReeves 

Definition at line 38 of file ConjugateGradient.h.

enum Purple::ConjugateGradient::OptimalStepSizeMethod

Enumeration of the available optimization operators for the optimal step sizes.

Enumerator:
GoldenSection 
BrentMethod 

Definition at line 43 of file ConjugateGradient.h.


Constructor & Destructor Documentation

Purple::ConjugateGradient::ConjugateGradient ( ObjectiveFunction newObjectiveFunction  ) 

General constructor. It creates a conjugate gradient optimization algorithm object associated to an objective function object. It also initializes the class members to their default values:

Initial argument: Random point whithin the objective function domain.

Optimization operators:

Optimization parameters:

Stopping criteria:

User stuff:

Parameters:
newObjectiveFunction,: Pointer to an objective function object.
See also:
ObjectiveFunction.

OptimizationAlgorithm.

Definition at line 65 of file ConjugateGradient.cpp.

Purple::ConjugateGradient::ConjugateGradient ( void   ) 

Default constructor. It creates a conjugate gradient optimization algorithm object not associated to any objective function object. It also initializes the class members to their default values:

Optimization operators:

Optimization parameters:

Stopping criteria:

User stuff:

See also:
OptimizationAlgorithm.

Definition at line 146 of file ConjugateGradient.cpp.

Purple::ConjugateGradient::~ConjugateGradient ( void   )  [virtual]

Destructor.

Definition at line 176 of file ConjugateGradient.cpp.


Member Function Documentation

double Purple::ConjugateGradient::getPolakRibiereParameter ( Vector< double >  oldGradient,
Vector< double >  gradient 
) [private]

This method returns the Polak-Ribiere parameter used to get the search direction.

Parameters:
oldGradient,: Previous objective function gradient.
gradient,: Current objective function gradient.
See also:
getPolakRibiereSearchDirection(Vector<double>, Vector<double>, Vector<double>).

Definition at line 593 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getFletcherReevesParameter ( Vector< double >  oldGradient,
Vector< double >  gradient 
) [private]

This method returns the Fletcher-Reeves parameter used to get the search direction.

Parameters:
oldGradient,: Previous objective function gradient.
gradient,: Current objective function gradient.
See also:
getFletcherReevesSearchDirection(Vector<double>, Vector<double>, Vector<double>).

Definition at line 540 of file ConjugateGradient.cpp.

Vector< double > Purple::ConjugateGradient::getFletcherReevesSearchDirection ( Vector< double >  oldGradient,
Vector< double >  gradient,
Vector< double >  oldSearchDirection 
) [private]

This method returns the search direction using the Fletcher-Reeves update.

Parameters:
oldGradient,: Previous objective function gradient.
gradient,: Current objective function gradient.
oldSearchDirection,: Previous search direction Vector.
See also:
getFletcherReevesParameter(Vector<double>, Vector<double>).

getPolakRibiereParameter(Vector<double>, Vector<double>)

getPolakRibiereSearchDirection(Vector<double>, Vector<double>, Vector<double>)

Definition at line 649 of file ConjugateGradient.cpp.

Vector< double > Purple::ConjugateGradient::getPolakRibiereSearchDirection ( Vector< double >  oldGradient,
Vector< double >  gradient,
Vector< double >  oldSearchDirection 
) [private]

This method returns the search direction using the Polak-Ribiere update.

Parameters:
oldGradient,: Previous objective function gradient.
gradient,: Current objective function gradient.
oldSearchDirection,: Previous search direction Vector.
See also:
getPolakRibiereParameter(Vector<double>, Vector<double>).

getFletcherReevesParameter(Vector<double>, Vector<double>).

getFletcherReevesSearchDirection(Vector<double>, Vector<double>, Vector<double>).

Definition at line 682 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getGoldenSectionOptimalStepSize ( double  initialStepSize,
double  evaluation,
Vector< double >  argument,
Vector< double >  searchDirection 
) [private]

This method returns the optimal step size by searching in a given direction to locate the minimum of the objective function in that direction. It uses the golden section method.

Parameters:
initialStepSize,: Initial step size in line search.
evaluation,: Objective function evaluation value.
argument,: Objective function argument Vector.
searchDirection,: Search direction Vector.
See also:
getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 715 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getBrentMethodOptimalStepSize ( double  initialStepSize,
double  evaluation,
Vector< double >  argument,
Vector< double >  searchDirection 
) [private]

This method returns the optimal step size by searching in a given direction to locate the minimum of the objective function in that direction. It uses the Brent's method.

Parameters:
initialStepSize,: Initial step size in line search.
evaluation,: Objective function evaluation value.
argument,: Objective function argument Vector.
searchDirection,: Search direction Vector.
See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 935 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getMinimum ( Vector< double >  v  )  [private]

This method returns the minimum element in a Vector of double precision numbers.

Parameters:
v,: Vector of double precision numbers.
See also:
getGoldenSectionStepSize(double, double, Vector<double>, Vector<double>)

Definition at line 2126 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getMaximum ( Vector< double >  v  )  [private]

This method returns the maximum element in a Vector of double precision numbers.

Parameters:
v,: Vector of double precision numbers.
See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>)

Definition at line 2152 of file ConjugateGradient.cpp.

ConjugateGradient::SearchDirectionMethod Purple::ConjugateGradient::getSearchDirectionMethod ( void   ) 

This method returns the search direction method used for optimization.

See also:
getFletcherReevesSearchDirection(Vector<double>, Vector<double>, Vector<double>).

getPolakRibiereSearchDirection(Vector<double>, Vector<double>, Vector<double>).

Definition at line 192 of file ConjugateGradient.cpp.

ConjugateGradient::OptimalStepSizeMethod Purple::ConjugateGradient::getOptimalStepSizeMethod ( void   ) 

This method returns the optimal step size method used for optimization.

See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 206 of file ConjugateGradient.cpp.

Vector< double > Purple::ConjugateGradient::getInitialArgument ( void   ) 

This method returns the initial objective function argument to be used by the conjugate gradient method for optimization.

Definition at line 217 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getGradientNormGoal ( void   ) 

This method returns the goal value for the norm of the objective function gradient. This is used as a stopping criterium when optimizing a function.

Definition at line 229 of file ConjugateGradient.cpp.

int Purple::ConjugateGradient::getMaximumNumberOfIterations ( void   ) 

This method returns the maximum number of iterations to be performed by the conjugate gradient method during the optimization process. This is used as a stopping criterium when optimizing an objective function.

Definition at line 241 of file ConjugateGradient.cpp.

int Purple::ConjugateGradient::getShowPeriod ( void   ) 

This method returns the number of iterations between the optimization showing progress.

Definition at line 293 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getFirstStepSize ( void   ) 

This method returns the initial step size for line search in the first iteration of the conjugate gradient.

See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 255 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getOptimalStepSizeTolerance ( void   ) 

This method returns the tolerance value in line search.

See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 268 of file ConjugateGradient.cpp.

double Purple::ConjugateGradient::getWarningStepSize ( void   ) 

This method returns the step size value at wich a warning message is written to the screen during line search.

See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 282 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setSearchDirectionMethod ( ConjugateGradient::SearchDirectionMethod  newSearchDirectionMethod  ) 

This method sets a new search direction method to be used for otpimization with the conjugate gradient method.

Parameters:
newSearchDirectionMethod,: Search direction method.
See also:
getFletcherReevesSearchDirection(Vector<double>, Vector<double>, Vector<double>).

getPolakRibiereSearchDirection(Vector<double>, Vector<double>, Vector<double>).

Definition at line 310 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setOptimalStepSizeMethod ( ConjugateGradient::OptimalStepSizeMethod  newOptimalStepSizeMethod  ) 

This method sets a new optimal step size method to be used for optimization with the conjugate gradient method.

Parameters:
newOptimalStepSizeMethod,: Optimal step size method.
See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 327 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setFirstStepSize ( double  newFirstStepSize  ) 

This method sets a new initial step size for line search in the first iteration of the conjugate gradient.

Parameters:
newFirstStepSize,: First step size.
See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 452 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setOptimalStepSizeTolerance ( double  newOptimalStepSizeTolerance  ) 

This method sets a new tolerance value to be used in line line search.

Parameters:
newOptimalStepSizeTolerance,: Tolerance value.
See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 482 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setInitialArgument ( Vector< double >  newInitialArgument  ) 

This method sets a new initial objective function argument to be used by the conjugate gradient method for optimization.

Parameters:
newInitialArgument,: Initial argument Vector.

Definition at line 340 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setGradientNormGoal ( double  newGradientNormGoal  ) 

This method sets a new the goal value for the norm of the objective function gradient. This is used as a stopping criterium when optimizing an objective function.

Parameters:
newGradientNormGoal,: Goal value for the norm of the objective function gradient.

Definition at line 370 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setMaximumNumberOfIterations ( int  newMaximumNumberOfIterations  ) 

This method sets a new maximum number of conjugate gradient iterations for optimization.

Parameters:
newMaximumNumberOfIterations,: Maximum number of iterations.

Definition at line 397 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setShowPeriod ( int  newShowPeriod  ) 

This sets a new number of iterations between the optimization showing progress.

Parameters:
newShowPeriod,: Show period.

Definition at line 422 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::setWarningStepSize ( double  newWarningStepSize  ) 

This method sets a new step size value at wich a warning message is written to the screen during line search.

Parameters:
newWarningStepSize,: Warning step size value.
See also:
getGoldenSectionOptimalStepSize(double, double, Vector<double>, Vector<double>).

getBrentMethodOptimalStepSize(double, double, Vector<double>, Vector<double>).

Definition at line 512 of file ConjugateGradient.cpp.

Vector< double > Purple::ConjugateGradient::getMinimalArgument ( void   )  [virtual]

This method optimizes an objective function according to the conjugate gradient algorithm. It returns the minimal argument of the objective function. Optimization occurs according to the optimization operators and the optimization parameters.

Implements Purple::OptimizationAlgorithm.

Definition at line 1238 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::print ( void   ) 

This method prints to the screen the optimization operators and the optimization parameters concerning the conjugate gradient object:

Initial argument.

Optimization operators:

Optimization parameters:

Stopping criteria:

User stuff:

Definition at line 1641 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::load ( char *  filename  ) 

This method loads a conjugate gradient object from a data file. Please mind about the file format, wich is specified in the User's Guide.

Initial argument.

Optimization operators:

Optimization parameters:

Stopping criteria:

User stuff:

Parameters:
filename,: Filename.
See also:
save(char*).

Definition at line 1928 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::save ( char *  filename  ) 

This method saves the conjugate gradient object to a data file.

Initial argument.

Optimization operators:

Optimization parameters:

Stopping criteria:

User stuff:

Parameters:
filename,: Filename.
See also:
load(char*).

Definition at line 1775 of file ConjugateGradient.cpp.

void Purple::ConjugateGradient::saveOptimizationHistory ( char *  filename  ) 

This method saves the optimization history to a data file:

  1. Iteration.
  2. Objective function evaluation.
  3. Objective function gradient norm.

Parameters:
filename,: Filename.

Definition at line 2069 of file ConjugateGradient.cpp.


Member Data Documentation

Vector<double> Purple::ConjugateGradient::initialArgument [private]

Initial argument.

Definition at line 51 of file ConjugateGradient.h.

double Purple::ConjugateGradient::gradientNormGoal [private]

Objective function gradient norm goal. It is used as a stopping criterion.

Definition at line 56 of file ConjugateGradient.h.

int Purple::ConjugateGradient::maximumNumberOfIterations [private]

Maximum number of iterations. It is used as an optimization stopping criterion.

Definition at line 61 of file ConjugateGradient.h.

int Purple::ConjugateGradient::showPeriod [private]

Number of iterations between the optimization showing progress.

Definition at line 65 of file ConjugateGradient.h.

double Purple::ConjugateGradient::firstStepSize [private]

Initial step size in line minimization.

Definition at line 69 of file ConjugateGradient.h.

double Purple::ConjugateGradient::optimalStepSizeTolerance [private]

Tolerance in optimal step size.

Definition at line 73 of file ConjugateGradient.h.

double Purple::ConjugateGradient::warningStepSize [private]

Step size at wich a warning message is written to the screen during line minimization.

Definition at line 78 of file ConjugateGradient.h.

Vector<double> Purple::ConjugateGradient::evaluationHistory [private]

Evaluation history.

Definition at line 82 of file ConjugateGradient.h.

Vector<double> Purple::ConjugateGradient::gradientNormHistory [private]

Norm of objective function gradient history.

Definition at line 86 of file ConjugateGradient.h.

SearchDirectionMethod Purple::ConjugateGradient::searchDirectionMethod [private]

Definition at line 111 of file ConjugateGradient.h.

OptimalStepSizeMethod Purple::ConjugateGradient::optimalStepSizeMethod [private]

Definition at line 115 of file ConjugateGradient.h.


Generated on Wed Jun 21 13:10:38 2006 for Purple by  doxygen 1.4.7