MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / twoLoopHp

Method twoLoopHp

JSAT/src/jsat/math/optimization/LBFGS.java:68–93  ·  view source on GitHub ↗

See Algorithm 7.4 (L-BFGS two-loop recursion). @param x_grad the initial value ∇ f k @param rho @param s @param y @param q the location to store the value of H k ∇ f k @param alphas temp space to do work, should be as large as the number of history vectors

(Vec x_grad, List<Double> rho, List<Vec> s, List<Vec> y, Vec q, double[] alphas)

Source from the content-addressed store, hash-verified

66 * @param alphas temp space to do work, should be as large as the number of history vectors
67 */
68 public static void twoLoopHp(Vec x_grad, List<Double> rho, List<Vec> s, List<Vec> y, Vec q, double[] alphas)
69 {
70 //q ← ∇ fk;
71 x_grad.copyTo(q);
72 if(s.isEmpty())
73 return;//identity, we are done
74 //for i = k−1,k−2,...,k−m
75 for(int i = 0; i < s.size(); i++)
76 {
77 Vec s_i = s.get(i);
78 Vec y_i = y.get(i);
79 double alpha_i = alphas[i] = rho.get(i)*s_i.dot(q);
80 q.mutableSubtract(alpha_i, y_i);
81 }
82
83 //r ← Hk0q; and see eq (7.20), done in place in q
84 q.mutableMultiply(s.get(0).dot(y.get(0))/y.get(0).dot(y.get(0)));
85 //for i = k−m,k−m+1,...,k−1
86 for(int i = s.size()-1; i >= 0; i--)
87 {
88 //β ← ρ_i y_i^T r ;
89 double beta = rho.get(i)*y.get(i).dot(q);
90 //r ← r + si (αi − β)
91 q.mutableAdd(alphas[i]-beta, s.get(i));
92 }
93 }
94
95 @Override
96 public void optimize(double tolerance, Vec w, Vec x0, Function f, FunctionVec fp, FunctionVec fpp)

Callers 2

optimizeMethod · 0.95
optimizeMethod · 0.95

Calls 7

dotMethod · 0.95
sizeMethod · 0.65
copyToMethod · 0.45
getMethod · 0.45
mutableSubtractMethod · 0.45
mutableMultiplyMethod · 0.45
mutableAddMethod · 0.45

Tested by

no test coverage detected