[mlpack-git] master, mlpack-1.0.x: Rearrange parameters -- maxIterations is probably the most likely to be changed, and also maxIterations tends to be the first parameter for other algorithms. (11d78cd)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:50:40 EST 2015
Repository : https://github.com/mlpack/mlpack
On branches: master,mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit 11d78cd22f36701eca591bd566b71548ed307f4b
Author: Ryan Curtin <ryan at ratml.org>
Date: Wed Jul 2 20:59:39 2014 +0000
Rearrange parameters -- maxIterations is probably the most likely to be changed, and also maxIterations tends to be the first parameter for other algorithms.
>---------------------------------------------------------------
11d78cd22f36701eca591bd566b71548ed307f4b
src/mlpack/core/optimizers/sa/sa.hpp | 25 ++++++++++++++-----------
src/mlpack/core/optimizers/sa/sa_impl.hpp | 8 ++++----
src/mlpack/tests/sa_test.cpp | 2 +-
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/mlpack/core/optimizers/sa/sa.hpp b/src/mlpack/core/optimizers/sa/sa.hpp
index 14a1640..cecf86c 100644
--- a/src/mlpack/core/optimizers/sa/sa.hpp
+++ b/src/mlpack/core/optimizers/sa/sa.hpp
@@ -54,22 +54,24 @@ class SA
{
public:
/*
- * Construct the SA optimizer with the given function and paramters.
+ * Construct the SA optimizer with the given function and parameters.
*
* @param function Function to be minimized.
- * @param coolingSchedule Cooling schedule
+ * @param coolingSchedule Instantiated cooling schedule.
+ * @param maxIterations Maximum number of iterations allowed (0 indicates no limit).
* @param initT Initial temperature.
- * @param initMoves Iterations without changing temperature.
- * @param moveCtrlSweep Sweeps per move control.
+ * @param initMoves Number of initial iterations without changing temperature.
+ * @param moveCtrlSweep Sweeps per feedback move control.
* @param tolerance Tolerance to consider system frozen.
- * @param maxToleranceSweep Maximum sweeps below tolerance to consider system frozen.
+ * @param maxToleranceSweep Maximum sweeps below tolerance to consider system
+ * frozen.
* @param maxMoveCoef Maximum move size.
* @param initMoveCoef Initial move size.
* @param gain Proportional control in feedback move control.
- * @param maxIterations Maximum number of iterations allowed (0 indicates no limit).
*/
SA(FunctionType& function,
CoolingScheduleType& coolingSchedule,
+ const size_t maxIterations = 1000000,
const double initT = 10000.,
const size_t initMoves = 1000,
const size_t moveCtrlSweep = 100,
@@ -77,9 +79,10 @@ class SA
const size_t maxToleranceSweep = 3,
const double maxMoveCoef = 20,
const double initMoveCoef = 0.3,
- const double gain = 0.3,
- const size_t maxIterations = 1000000);
- /*
+ const double gain = 0.3);
+
+
+ /*&
* 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.
@@ -141,15 +144,15 @@ class SA
std::string ToString() const;
private:
- FunctionType &function;
+ FunctionType&function;
CoolingScheduleType &coolingSchedule;
+ size_t maxIterations;
double T;
size_t initMoves;
size_t moveCtrlSweep;
double tolerance;
size_t maxToleranceSweep;
double gain;
- size_t maxIterations;
arma::mat maxMove;
arma::mat moveSize;
diff --git a/src/mlpack/core/optimizers/sa/sa_impl.hpp b/src/mlpack/core/optimizers/sa/sa_impl.hpp
index 63f5bc7..d1833b8 100644
--- a/src/mlpack/core/optimizers/sa/sa_impl.hpp
+++ b/src/mlpack/core/optimizers/sa/sa_impl.hpp
@@ -19,6 +19,7 @@ template<
SA<FunctionType, CoolingScheduleType>::SA(
FunctionType& function,
CoolingScheduleType& coolingSchedule,
+ const size_t maxIterations,
const double initT,
const size_t initMoves,
const size_t moveCtrlSweep,
@@ -26,17 +27,16 @@ SA<FunctionType, CoolingScheduleType>::SA(
const size_t maxToleranceSweep,
const double maxMoveCoef,
const double initMoveCoef,
- const double gain,
- const size_t maxIterations) :
+ const double gain) :
function(function),
coolingSchedule(coolingSchedule),
+ maxIterations(maxIterations),
T(initT),
initMoves(initMoves),
moveCtrlSweep(moveCtrlSweep),
tolerance(tolerance),
maxToleranceSweep(maxToleranceSweep),
- gain(gain),
- maxIterations(maxIterations)
+ gain(gain)
{
const size_t rows = function.GetInitialPoint().n_rows;
const size_t cols = function.GetInitialPoint().n_cols;
diff --git a/src/mlpack/tests/sa_test.cpp b/src/mlpack/tests/sa_test.cpp
index 905373f..f2878cc 100644
--- a/src/mlpack/tests/sa_test.cpp
+++ b/src/mlpack/tests/sa_test.cpp
@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(GeneralizedRosenbrockTest)
ExponentialSchedule schedule(1e-5);
SA<GeneralizedRosenbrockFunction, ExponentialSchedule>
- sa(f, schedule, 1000.,1000, 100, 1e-9, 3, 20, 0.3, 0.3, 10000000);
+ sa(f, schedule, 10000000, 1000.,1000, 100, 1e-9, 3, 20, 0.3, 0.3);
arma::mat coordinates = f.GetInitialPoint();
double result = sa.Optimize(coordinates);
More information about the mlpack-git
mailing list