update_full_correction.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_OPTIMIZERS_FW_UPDATE_FULL_CORRECTION_HPP
15 #define MLPACK_CORE_OPTIMIZERS_FW_UPDATE_FULL_CORRECTION_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 #include "atoms.hpp"
19 
20 namespace mlpack {
21 namespace optimization {
22 
38 {
39  public:
46  UpdateFullCorrection(const double tau, const double stepSize) :
47  tau(tau), stepSize(stepSize)
48  { /* Do nothing. */ }
49 
60  void Update(FuncSq& function,
61  const arma::mat& oldCoords,
62  const arma::mat& s,
63  arma::mat& newCoords,
64  const size_t /* numIter */)
65  {
66  // Line search, with explicit solution here.
67  arma::mat v = tau * s - oldCoords;
68  arma::mat b = function.Vectorb();
69  arma::mat A = function.MatrixA();
70  double gamma = arma::dot(b - A * oldCoords, A * v);
71  gamma = gamma / std::pow(arma::norm(A * v, "fro"), 2);
72  gamma = std::min(gamma, 1.0);
73  atoms.CurrentCoeffs() = (1.0 - gamma) * atoms.CurrentCoeffs();
74  atoms.AddAtom(s, function, gamma * tau);
75 
76  // Projected gradient method for enhancement.
77  atoms.ProjectedGradientEnhancement(function, tau, stepSize);
78  atoms.RecoverVector(newCoords);
79  }
80 
81  private:
83  double tau;
84 
86  double stepSize;
87 
89  Atoms atoms;
90 };
91 
92 } // namespace optimization
93 } // namespace mlpack
94 
95 #endif
Square loss function .
Definition: func_sq.hpp:25
Class to hold the information and operations of current atoms in the soluton space.
Definition: atoms.hpp:25
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
const arma::vec & CurrentCoeffs() const
Get the current atom coefficients.
Definition: atoms.hpp:198
void RecoverVector(arma::mat &x)
Recover the solution coordinate from the coefficients of current atoms.
Definition: atoms.hpp:61
void Update(FuncSq &function, const arma::mat &oldCoords, const arma::mat &s, arma::mat &newCoords, const size_t)
Update rule for FrankWolfe, recalculate the coefficents of of current atoms, while satisfying the nor...
void ProjectedGradientEnhancement(FuncSq &function, double tau, double stepSize, size_t maxIteration=100, double tolerance=1e-3)
Enhance the solution in the convex hull of current atoms with atom norm constraint tau...
Definition: atoms.hpp:165
Full correction approach to update the solution.
UpdateFullCorrection(const double tau, const double stepSize)
Construct UpdateFullCorrection class.
void AddAtom(const arma::vec &v, FuncSq &function, const double c=0)
Add atom into the solution space.
Definition: atoms.hpp:36