[mlpack] 108/324: Rename parameters, clean up documentation; very minor tweaks. No functionality changes.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:22:01 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 0e9c71eb7845433bb1e2595e4dcb6d3278052371
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Wed Jul 2 21:04:59 2014 +0000
Rename parameters, clean up documentation; very minor tweaks. No functionality changes.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16746 9d5b8971-822b-0410-80eb-d18c1038ef23
---
src/mlpack/core/optimizers/sa/sa.hpp | 71 ++++++++++++++++++-------------
src/mlpack/core/optimizers/sa/sa_impl.hpp | 8 ++--
2 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/src/mlpack/core/optimizers/sa/sa.hpp b/src/mlpack/core/optimizers/sa/sa.hpp
index cecf86c..57e2734 100644
--- a/src/mlpack/core/optimizers/sa/sa.hpp
+++ b/src/mlpack/core/optimizers/sa/sa.hpp
@@ -93,67 +93,80 @@ class SA
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 the maximum number of iterations.
+ size_t MaxIterations() const { return maxIterations; }
+ //! Modify the maximum number of iterations.
+ 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 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;}
+ //! 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;
diff --git a/src/mlpack/core/optimizers/sa/sa_impl.hpp b/src/mlpack/core/optimizers/sa/sa_impl.hpp
index d1833b8..fc2ac5c 100644
--- a/src/mlpack/core/optimizers/sa/sa_impl.hpp
+++ b/src/mlpack/core/optimizers/sa/sa_impl.hpp
@@ -31,7 +31,7 @@ SA<FunctionType, CoolingScheduleType>::SA(
function(function),
coolingSchedule(coolingSchedule),
maxIterations(maxIterations),
- T(initT),
+ temperature(initT),
initMoves(initMoves),
moveCtrlSweep(moveCtrlSweep),
tolerance(tolerance),
@@ -78,7 +78,7 @@ double SA<FunctionType, CoolingScheduleType>::Optimize(arma::mat &iterate)
{
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 @@ void SA<FunctionType, CoolingScheduleType>::GenerateMove(
// 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 @@ ToString() const
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;
--
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