[mlpack] 107/324: Rearrange parameters -- maxIterations is probably the most likely to be changed, and also maxIterations tends to be the first parameter for other algorithms.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:22:00 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit 901316b82b611779f736addf24eaffec40f7beda
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
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.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16745 9d5b8971-822b-0410-80eb-d18c1038ef23
---
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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list