Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fb74645
Initial commit and skeleton for NonlinearMinimizer
Jan 30, 2015
a7ee059
Merge branch 'qp' of https://github.com/debasish83/breeze into nlqp
Jan 31, 2015
679bb5f
Skeleton for approximate eigen value calculation
Feb 2, 2015
3d80b31
Copyright message for NonlinearMinimizer
Feb 2, 2015
3781e37
merge with qp branch; NOTICE file updated
Feb 3, 2015
536886d
Initial checkin for PowerMethod and PowerMethodTest;Eigen value extra…
Feb 3, 2015
f98bd80
Compilation fixes to LBFGS eigenMin and eigenMax
Feb 4, 2015
ae795b6
Power Method merged; NonlinearMinimizer now supports preserving histo…
Feb 11, 2015
51b4224
Generating PQN.CompactHessian from BFGS.ApproximateInverseHessian not…
Feb 11, 2015
ee697bf
Linear Regression formulation added for comparisons
Feb 11, 2015
ce8638f
Fixed LBFGS.maxEigen using power law on CompactHessian
Feb 12, 2015
bbc3edd
Merge branch 'qp' of https://github.com/debasish83/breeze into nlqp
Feb 17, 2015
f85ff86
Merge branch 'qp' of https://github.com/debasish83/breeze into nlqp
Feb 22, 2015
e3a61a9
Added a proximal interface to ProjectQuasiNewton solver; Added projec…
Feb 23, 2015
928de32
probability simplex benchmark
Feb 24, 2015
91f2e17
After experimentation NonlinearMinimizer now users PQN/OWLQN and supp…
Feb 28, 2015
33d28ff
Add testcases for Least square variants
Mar 1, 2015
6cba897
merge with upstream
Mar 1, 2015
9bef354
I dunno.
dlwh Mar 1, 2015
18c7789
PQN fixes from David's fix_pqn branch; added strong wolfe line search…
Mar 2, 2015
43794c0
Unused import from FirstOrderMinimizer; PQN migrated to Strong Wolfe …
Mar 5, 2015
e2c1db8
Used BacktrackingLineSearch in SPG and PQN; Updated NonlinearMinimize…
Mar 5, 2015
defaff5
NonlinearMinimizer println changed to nl from pqn
Mar 5, 2015
610027f
Updated with cforRange in proximal operations
Mar 7, 2015
8c6a6c8
BacktrackingLineSearch takes an initfval;OWLQN, PQN and SPG updated t…
Mar 7, 2015
b4d86e8
Merge branch 'master' of https://github.com/scalanlp/breeze into nlqp
Mar 7, 2015
3a6fc97
infiniteIteration API in FirstOrderMinimizer takes initialState;PQN b…
Mar 11, 2015
8533ada
migrate LBFGS Eigen calculation to https://github.com/debasish83/bree…
Mar 11, 2015
a0bbd33
cleaned up minEigen call from QuadraticMinimizer
Mar 11, 2015
40a45a8
NonlinearMinimizer inner iterations through BFGS cleaned
Mar 12, 2015
7308c7a
Updated contributions in README.md
Mar 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed LBFGS.maxEigen using power law on CompactHessian
  • Loading branch information
Debasish Das committed Feb 12, 2015
commit ce8638fb697880158971e1dd70b94841e066e166
14 changes: 8 additions & 6 deletions math/src/main/scala/breeze/optimize/LBFGS.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ class LBFGS[T](maxIter: Int = -1, m: Int=10, tolerance: Double=1E-9)
* @param state the current state of the optimization
* @return minimium eigen eigen value
*/
def minEigen(init:T, state: State) : Double = {
def minEigen(state: State, init: T) : Double = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it make more sense for these to be methods on LBFGS' companion or something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, that solves the issue with the DenseVector casting. If it's on the LBFGS companion, you can just force it to be DenseVector[Double]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just checking on this again. Why not make this a method on LBFGS.ApproximateInverseHessian directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I will clean it...I will also add similar method on ProjectedQuasiNewton.CompactHessian...seems like they will be useful in Block Coordinate Descent ideas...

val pm = new PowerMethod[T, LBFGS.ApproximateInverseHessian[T]]()(space,LBFGS.multiplyInverseHessian)
val eigenMax = pm.eigen(init, state.history)
1.0/eigenMax
val eigenState = pm.iterateAndReturnState(init, state.history)
logger.info(s"LBFGS Min Eigen iterations ${eigenState.iter}")
1.0/eigenState.eigenValue
}

/**
Expand All @@ -105,14 +106,15 @@ class LBFGS[T](maxIter: Int = -1, m: Int=10, tolerance: Double=1E-9)
* @param state the current state of the optimization
* @return maximum eigen value
*/
def maxEigen(init:T, state: State) : Double = {
println(s"m ${state.history.m} historyLength ${state.history.historyLength}")
def maxEigen(state: State, init: T) : Double = {
val compactHessian = new CompactHessian(state.history.m)
val memStep = state.history.memStep.asInstanceOf[Seq[DenseVector[Double]]]
val memGradDelta = state.history.memGradDelta.asInstanceOf[Seq[DenseVector[Double]]]
(0 to state.history.historyLength - 1).map{i => compactHessian.updated(memStep(i), memGradDelta(i))}
val pm = new PowerMethod[T, CompactHessian]()(space, ProjectedQuasiNewton.multiplyCompactHessian)
pm.eigen(init, compactHessian)
val eigenState = pm.iterateAndReturnState(init, compactHessian)
logger.info(s"LBFGS Max Eigen iterations ${eigenState.iter}")
eigenState.eigenValue
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ object ProjectedQuasiNewton {

implicit def multiplyCompactHessian[T](implicit vspace: MutableInnerProductModule[T, Double]): OpMulMatrix.Impl2[CompactHessian, T, T] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this definitely has to go.

new OpMulMatrix.Impl2[CompactHessian, T, T] {
def apply(a: CompactHessian, b: T): T = a * b
def apply(a: CompactHessian, b: T): T = {
val result = a * b.asInstanceOf[DenseVector[Double]]
result.asInstanceOf[T]
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ class NonlinearMinimizer(ndim: Int,
}

var initialState = primalSolve.minimizeAndReturnState(primal, init)

println(s"Quadratic Model minEigen ${primalSolve.minEigen(init, initialState)}")

val proxPrimal = ProximalPrimal(primal, u, z, rho)

val xHat = DenseVector.zeros[Double](ndim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@

package breeze.optimize.proximal

import breeze.linalg.cholesky
import breeze.linalg.LU
import breeze.linalg._
import breeze.util.SerializableLogging
import scala.math.max
import scala.math.sqrt
import breeze.optimize.{LBFGS, OWLQN, DiffFunction}
import org.netlib.util.intW
import breeze.optimize.proximal.Constraint._
import scala.math.abs
import breeze.linalg.DenseVector
import breeze.linalg.DenseMatrix
import breeze.numerics._
import breeze.linalg.LapackException
import breeze.linalg.norm
import com.github.fommil.netlib.LAPACK.{getInstance=>lapack}
import breeze.optimize.linear.{PowerMethod, NNLS, ConjugateGradient}
import breeze.stats.distributions.Rand
Expand Down Expand Up @@ -418,7 +412,16 @@ object QuadraticMinimizer {
H: DenseMatrix[Double],
q: DenseVector[Double]) = {
val lbfgs = new LBFGS[DenseVector[Double]](-1, 7)
lbfgs.minimize(Cost(H, q), init)
val state = lbfgs.minimizeAndReturnState(Cost(H, q), init)
val approxMinEigen = lbfgs.minEigen(state, init)
val approxMaxEigen = lbfgs.maxEigen(state, init)
val eigs = eigSym(H).eigenvalues

val minEigen = min(eigs)
val maxEigen = max(eigs)
println(s"minEigen $minEigen approx $approxMinEigen maxEigen $maxEigen approx $approxMaxEigen")

state.x
}

def optimizeWithOWLQN(init: DenseVector[Double],
Expand Down