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,
85 CoolingScheduleType& coolingSchedule,
86 const size_t maxIterations = 1000000,
87 const double initT = 10000.,
88 const size_t initMoves = 1000,
89 const size_t moveCtrlSweep = 100,
90 const double tolerance = 1e-5,
91 const size_t maxToleranceSweep = 3,
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; }
137 double Gain()
const {
return gain; }
139 double&
Gain() {
return gain; }
158 FunctionType&
function;
160 CoolingScheduleType& coolingSchedule;
162 size_t maxIterations;
168 size_t moveCtrlSweep;
172 size_t maxToleranceSweep;
196 void GenerateMove(arma::mat& iterate,
200 size_t& sweepCounter);
220 void MoveControl(
const size_t nMoves, arma::mat& accept);
226 #include "sa_impl.hpp" FunctionType & Function()
Modify the instantiated function.
size_t MaxIterations() const
Get the maximum number of iterations.
size_t & MaxIterations()
Modify the maximum number of iterations.
Linear algebra utility functions, generally performed on matrices or vectors.
double Temperature() const
Get the temperature.
double Gain() const
Get the gain.
Simulated Annealing is an stochastic optimization algorithm which is able to deliver near-optimal res...
double & Gain()
Modify the gain.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Tolerance() const
Get the tolerance.
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.
size_t & MoveCtrlSweep()
Modify sweeps per move control.
size_t InitMoves() const
Get the initial moves.
const FunctionType & Function() const
Get the instantiated function to be optimized.
double Optimize(arma::mat &iterate)
Optimize the given function using simulated annealing.
arma::mat & MaxMove()
Modify the maximum move size of each parameter.
arma::mat MaxMove() const
Get the maximum move size of each parameter.
size_t MaxToleranceSweep() const
Get the maxToleranceSweep.
double & Tolerance()
Modify the tolerance.
size_t & InitMoves()
Modify the initial moves.
size_t & MaxToleranceSweep()
Modify the maxToleranceSweep.
arma::mat MoveSize() const
Get move size of each parameter.
arma::mat & MoveSize()
Modify move size of each parameter.
double & Temperature()
Modify the temperature.
size_t MoveCtrlSweep() const
Get sweeps per move control.