[mlpack-svn] r16746 - mlpack/trunk/src/mlpack/core/optimizers/sa

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


Author: rcurtin
Date: Wed Jul  2 17:04:59 2014
New Revision: 16746

Log:
Rename parameters, clean up documentation; very minor tweaks.  No functionality changes.


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

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 17:04:59 2014
@@ -93,67 +93,80 @@
   double Optimize(arma::mat& iterate);
 
   //! Get the instantiated function to be optimized.
-  const FunctionType& Function() const {return function;}
+  const FunctionType& Function() const { return function; }
   //! Modify the instantiated function.
-  FunctionType& Function() {return function;}
+  FunctionType& Function() { return function; }
 
   //! Get the temperature.
-  double Temperature() const {return T;}
+  double Temperature() const { return temperature; }
   //! Modify the temperature.
-  double& Temperature() {return T;}
+  double& Temperature() { return temperature; }
 
   //! Get the initial moves.
-  size_t InitMoves() const {return initMoves;}
+  size_t InitMoves() const { return initMoves; }
   //! Modify the initial moves.
-  size_t& InitMoves() {return initMoves;}
+  size_t& InitMoves() { return initMoves; }
 
   //! Get sweeps per move control.
-  size_t MoveCtrlSweep() const {return moveCtrlSweep;}
+  size_t MoveCtrlSweep() const { return moveCtrlSweep; }
   //! Modify sweeps per move control.
-  size_t& MoveCtrlSweep() {return moveCtrlSweep;}
+  size_t& MoveCtrlSweep() { return moveCtrlSweep; }
 
   //! Get the tolerance.
-  double Tolerance() const {return tolerance;}
+  double Tolerance() const { return tolerance; }
   //! Modify the tolerance.
-  double& Tolerance() {return tolerance;}
+  double& Tolerance() { return tolerance; }
 
   //! Get the maxToleranceSweep.
-  size_t MaxToleranceSweep() const {return maxToleranceSweep;}
+  size_t MaxToleranceSweep() const { return maxToleranceSweep; }
   //! Modify the maxToleranceSweep.
-  size_t& MaxToleranceSweep() {return maxToleranceSweep;}
+  size_t& MaxToleranceSweep() { return maxToleranceSweep; }
 
   //! Get the gain.
-  double Gain() const {return gain;}
+  double Gain() const { return gain; }
   //! Modify the gain.
-  double& Gain() {return gain;}
+  double& Gain() { return gain; }
 
-  //! Get the maxIterations.
-  size_t MaxIterations() const {return maxIterations;}
-  //! Modify the maxIterations.
-  size_t& MaxIterations() {return maxIterations;}
-
-  //! Get Maximum move size of each parameter
-  arma::mat MaxMove() const {return maxMove;}
-  //! Modify maximum move size of each parameter
-  arma::mat& MaxMove() {return maxMove;}
-
-  //! Get move size of each parameter
-  arma::mat MoveSize() const {return moveSize;}
-  //! Modify  move size of each parameter
-  arma::mat& MoveSize() {return moveSize;}
+  //! Get the maximum number of iterations.
+  size_t MaxIterations() const { return maxIterations; }
+  //! Modify the maximum number of iterations.
+  size_t& MaxIterations() { return maxIterations; }
+
+  //! Get the maximum move size of each parameter.
+  arma::mat MaxMove() const { return maxMove; }
+  //! Modify the maximum move size of each parameter.
+  arma::mat& MaxMove() { return maxMove; }
+
+  //! Get move size of each parameter.
+  arma::mat MoveSize() const { return moveSize; }
+  //! Modify move size of each parameter.
+  arma::mat& MoveSize() { return moveSize; }
 
+  //! Return a string representation of this object.
   std::string ToString() const;
  private:
-  FunctionType&function;
-  CoolingScheduleType &coolingSchedule;
+  //! The function to be optimized.
+  FunctionType& function;
+  //! The cooling schedule being used.
+  CoolingScheduleType& coolingSchedule;
+  //! The maximum number of iterations.
   size_t maxIterations;
-  double T;
+  //! The current temperature.
+  double temperature;
+  //! The number of initial moves before reducing the temperature.
   size_t initMoves;
+  //! The number of sweeps before a MoveControl() call.
   size_t moveCtrlSweep;
+  //! Tolerance for convergence.
   double tolerance;
+  //! Number of sweeps in tolerance before system is considered frozen.
   size_t maxToleranceSweep;
+  //! Proportional control in feedback move control.
   double gain;
+
+  //! Maximum move size of each parameter.
   arma::mat maxMove;
+  //! Move size of each parameter.
   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 17:04:59 2014
@@ -31,7 +31,7 @@
     function(function),
     coolingSchedule(coolingSchedule),
     maxIterations(maxIterations),
-    T(initT),
+    temperature(initT),
     initMoves(initMoves),
     moveCtrlSweep(moveCtrlSweep),
     tolerance(tolerance),
@@ -78,7 +78,7 @@
   {
     oldEnergy = energy;
     GenerateMove(iterate);
-    T = coolingSchedule.nextTemperature(T, energy);
+    temperature = coolingSchedule.nextTemperature(temperature, energy);
 
     // Determine if the optimization has entered (or continues to be in) a
     // frozen state.
@@ -135,7 +135,7 @@
   // min{1, exp(-(E_new - E_old) / T)}.
   double xi = math::Random();
   double delta = energy - prevEnergy;
-  double criterion = std::exp(-delta / T);
+  double criterion = std::exp(-delta / temperature);
   if (delta <= 0. || criterion > xi)
   {
     accept(idx) += 1.;
@@ -209,7 +209,7 @@
   convert << util::Indent(function.ToString(), 2);
   convert << "  Cooling Schedule:" << std::endl;
   convert << util::Indent(coolingSchedule.ToString(), 2);
-  convert << "  Temperature: " << T << std::endl;
+  convert << "  Temperature: " << temperature << std::endl;
   convert << "  Initial moves: " << initMoves << std::endl;
   convert << "  Sweeps per move control: " << moveCtrlSweep << std::endl;
   convert << "  Tolerance: " << tolerance << std::endl;



More information about the mlpack-svn mailing list