[mlpack-svn] r16745 - in mlpack/trunk/src/mlpack: core/optimizers/sa tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Jul 2 16:59:40 EDT 2014


Author: rcurtin
Date: Wed Jul  2 16:59:39 2014
New Revision: 16745

Log:
Rearrange parameters -- maxIterations is probably the most likely to be changed, and also maxIterations tends to be the first parameter for other algorithms.


Modified:
   mlpack/trunk/src/mlpack/core/optimizers/sa/sa.hpp
   mlpack/trunk/src/mlpack/core/optimizers/sa/sa_impl.hpp
   mlpack/trunk/src/mlpack/tests/sa_test.cpp

Modified: mlpack/trunk/src/mlpack/core/optimizers/sa/sa.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/optimizers/sa/sa.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/optimizers/sa/sa.hpp	Wed Jul  2 16:59:39 2014
@@ -54,22 +54,24 @@
 {
  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 @@
      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 @@
 
   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;
 

Modified: mlpack/trunk/src/mlpack/core/optimizers/sa/sa_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/optimizers/sa/sa_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/optimizers/sa/sa_impl.hpp	Wed Jul  2 16:59:39 2014
@@ -19,6 +19,7 @@
 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 @@
     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;

Modified: mlpack/trunk/src/mlpack/tests/sa_test.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/tests/sa_test.cpp	(original)
+++ mlpack/trunk/src/mlpack/tests/sa_test.cpp	Wed Jul  2 16:59:39 2014
@@ -32,7 +32,7 @@
 
   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-svn mailing list