12 #ifndef MLPACK_CORE_OPTIMIZERS_SA_SA_HPP 13 #define MLPACK_CORE_OPTIMIZERS_SA_SA_HPP 20 namespace optimization {
62 typename FunctionType,
63 typename CoolingScheduleType = ExponentialSchedule
84 SA(FunctionType&
function,
87 const double initT = 10000.,
92 const double maxMoveCoef = 20,
93 const double initMoveCoef = 0.3,
94 const double gain = 0.3);
104 double Optimize(arma::mat& iterate);
107 const FunctionType&
Function()
const {
return function; }
158 FunctionType&
function;
200 size_t& sweepCounter);
220 void MoveControl(
const size_t nMoves, arma::mat& accept);
226 #include "sa_impl.hpp" size_t MaxToleranceSweep() const
Get the maxToleranceSweep.
size_t MoveCtrlSweep() const
Get sweeps per move control.
double gain
Proportional control in feedback move control.
arma::mat MoveSize() const
Get move size of each parameter.
arma::mat & MaxMove()
Modify the maximum move size of each parameter.
void MoveControl(const size_t nMoves, arma::mat &accept)
MoveControl() uses a proportional feedback control to determine the size parameter to pass to the mov...
size_t & MaxToleranceSweep()
Modify the maxToleranceSweep.
SA(FunctionType &function, 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 function and parameters.
Linear algebra utility functions, generally performed on matrices or vectors.
double & Gain()
Modify the gain.
Simulated Annealing is an stochastic optimization algorithm which is able to deliver near-optimal res...
double Optimize(arma::mat &iterate)
Optimize the given function using simulated annealing.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double temperature
The current temperature.
double & Tolerance()
Modify the tolerance.
size_t MaxIterations() const
Get the maximum number of iterations.
arma::mat MaxMove() const
Get the maximum move size of each parameter.
arma::mat maxMove
Maximum move size of each parameter.
void GenerateMove(arma::mat &iterate, arma::mat &accept, double &energy, size_t &idx, size_t &sweepCounter)
GenerateMove proposes a move on element iterate(idx), and determines if that move is acceptable or no...
double tolerance
Tolerance for convergence.
const FunctionType & Function() const
Get the instantiated function to be optimized.
double Tolerance() const
Get the tolerance.
double Temperature() const
Get the temperature.
arma::mat moveSize
Move size of each parameter.
size_t initMoves
The number of initial moves before reducing the temperature.
double Gain() const
Get the gain.
size_t & MoveCtrlSweep()
Modify sweeps per move control.
size_t InitMoves() const
Get the initial moves.
size_t & InitMoves()
Modify the initial moves.
size_t moveCtrlSweep
The number of sweeps before a MoveControl() call.
FunctionType & Function()
Modify the instantiated function.
CoolingScheduleType & coolingSchedule
The cooling schedule being used.
arma::mat & MoveSize()
Modify move size of each parameter.
size_t maxIterations
The maximum number of iterations.
double & Temperature()
Modify the temperature.
size_t & MaxIterations()
Modify the maximum number of iterations.
size_t maxToleranceSweep
Number of sweeps in tolerance before system is considered frozen.