mlpack  git-master
SA< CoolingScheduleType > Class Template Reference

Simulated Annealing is an stochastic optimization algorithm which is able to deliver near-optimal results quickly without knowing the gradient of the function being optimized. More...

Public Member Functions

 SA (CoolingScheduleType &coolingSchedule, const size_t maxIterations=1000000, const double initT=10000., const size_t initMoves=1000, const size_t moveCtrlSweep=100, const double tolerance=1e-5, const size_t maxToleranceSweep=3, const double maxMoveCoef=20, const double initMoveCoef=0.3, const double gain=0.3)
 Construct the SA optimizer with the given parameters. More...

 
double Gain () const
 Get the gain. More...

 
double & Gain ()
 Modify the gain. More...

 
size_t InitMoves () const
 Get the initial moves. More...

 
size_t & InitMoves ()
 Modify the initial moves. More...

 
size_t MaxIterations () const
 Get the maximum number of iterations. More...

 
size_t & MaxIterations ()
 Modify the maximum number of iterations. More...

 
size_t MaxToleranceSweep () const
 Get the maxToleranceSweep. More...

 
size_t & MaxToleranceSweep ()
 Modify the maxToleranceSweep. More...

 
size_t MoveCtrlSweep () const
 Get sweeps per move control. More...

 
size_t & MoveCtrlSweep ()
 Modify sweeps per move control. More...

 
template
<
typename
FunctionType
>
double Optimize (FunctionType &function, arma::mat &iterate)
 Optimize the given function using simulated annealing. More...

 
double Temperature () const
 Get the temperature. More...

 
double & Temperature ()
 Modify the temperature. More...

 
double Tolerance () const
 Get the tolerance. More...

 
double & Tolerance ()
 Modify the tolerance. More...

 

Detailed Description


template
<
typename
CoolingScheduleType
=
ExponentialSchedule
>

class mlpack::optimization::SA< CoolingScheduleType >

Simulated Annealing is an stochastic optimization algorithm which is able to deliver near-optimal results quickly without knowing the gradient of the function being optimized.

It has unique hill climbing capability that makes it less vulnerable to local minima. This implementation uses exponential cooling schedule and feedback move control by default, but the cooling schedule can be changed via a template parameter.

The algorithm keeps the temperature at initial temperature for initMove steps to get rid of the dependency on the initial condition. After that, it cools every step until the system is considered frozen or maxIterations is reached.

At each step, SA only perturbs one parameter at a time. When SA has perturbed all parameters in a problem, a sweep has been completed. Every moveCtrlSweep sweeps, the algorithm does feedback move control to change the average move size depending on the responsiveness of each parameter. Parameter gain controls the proportion of the feedback control.

The system is considered "frozen" when its score fails to change more then tolerance for maxToleranceSweep consecutive sweeps.

For SA to work, the FunctionType template class, used by the Optimize() method, must implement the following two methods:

double Evaluate(const arma::mat& coordinates); arma::mat& GetInitialPoint();

and the CoolingScheduleType parameter must implement the following method:

double NextTemperature(const double currentTemperature, const double currentValue);

which returns the next temperature given current temperature and the value of the function being optimized.

Template Parameters
CoolingScheduleTypetype for cooling schedule

Definition at line 61 of file sa.hpp.

Constructor & Destructor Documentation

◆ SA()

SA ( CoolingScheduleType &  coolingSchedule,
const size_t  maxIterations = 1000000,
const double  initT = 10000.,
const size_t  initMoves = 1000,
const size_t  moveCtrlSweep = 100,
const double  tolerance = 1e-5,
const size_t  maxToleranceSweep = 3,
const double  maxMoveCoef = 20,
const double  initMoveCoef = 0.3,
const double  gain = 0.3 
)

Construct the SA optimizer with the given parameters.

Parameters
coolingScheduleInstantiated cooling schedule.
maxIterationsMaximum number of iterations allowed (0 indicates no limit).
initTInitial temperature.
initMovesNumber of initial iterations without changing temperature.
moveCtrlSweepSweeps per feedback move control.
toleranceTolerance to consider system frozen.
maxToleranceSweepMaximum sweeps below tolerance to consider system frozen.
maxMoveCoefMaximum move size.
initMoveCoefInitial move size.
gainProportional control in feedback move control.

Member Function Documentation

◆ Gain() [1/2]

double Gain ( ) const
inline

Get the gain.

Definition at line 130 of file sa.hpp.

◆ Gain() [2/2]

double& Gain ( )
inline

Modify the gain.

Definition at line 132 of file sa.hpp.

◆ InitMoves() [1/2]

size_t InitMoves ( ) const
inline

Get the initial moves.

Definition at line 110 of file sa.hpp.

◆ InitMoves() [2/2]

size_t& InitMoves ( )
inline

Modify the initial moves.

Definition at line 112 of file sa.hpp.

◆ MaxIterations() [1/2]

size_t MaxIterations ( ) const
inline

Get the maximum number of iterations.

Definition at line 135 of file sa.hpp.

◆ MaxIterations() [2/2]

size_t& MaxIterations ( )
inline

Modify the maximum number of iterations.

Definition at line 137 of file sa.hpp.

◆ MaxToleranceSweep() [1/2]

size_t MaxToleranceSweep ( ) const
inline

Get the maxToleranceSweep.

Definition at line 125 of file sa.hpp.

◆ MaxToleranceSweep() [2/2]

size_t& MaxToleranceSweep ( )
inline

Modify the maxToleranceSweep.

Definition at line 127 of file sa.hpp.

◆ MoveCtrlSweep() [1/2]

size_t MoveCtrlSweep ( ) const
inline

Get sweeps per move control.

Definition at line 115 of file sa.hpp.

◆ MoveCtrlSweep() [2/2]

size_t& MoveCtrlSweep ( )
inline

Modify sweeps per move control.

Definition at line 117 of file sa.hpp.

◆ Optimize()

double Optimize ( FunctionType &  function,
arma::mat &  iterate 
)

Optimize the given function using simulated annealing.

The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.

Template Parameters
FunctionTypeType of function to optimize.
Parameters
functionFunction to optimize.
iterateStarting point (will be modified).
Returns
Objective value of the final point.

◆ Temperature() [1/2]

double Temperature ( ) const
inline

Get the temperature.

Definition at line 105 of file sa.hpp.

◆ Temperature() [2/2]

double& Temperature ( )
inline

Modify the temperature.

Definition at line 107 of file sa.hpp.

◆ Tolerance() [1/2]

double Tolerance ( ) const
inline

Get the tolerance.

Definition at line 120 of file sa.hpp.

◆ Tolerance() [2/2]

double& Tolerance ( )
inline

Modify the tolerance.

Definition at line 122 of file sa.hpp.


The documentation for this class was generated from the following file:
  • /var/www/www.mlpack.org/mlpack-git/src/mlpack/core/optimizers/sa/sa.hpp