Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified Newton using PositiveFactorizations #177

Merged
merged 1 commit into from
Mar 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.4
Calculus
DualNumbers 0.2
PositiveFactorizations
1 change: 1 addition & 0 deletions src/Optim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ VERSION >= v"0.4.0-dev+6521" && __precompile__(true)

module Optim
using Calculus
using PositiveFactorizations
using Compat

import Base.length,
Expand Down
10 changes: 7 additions & 3 deletions src/newton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ function optimize{T}(d::TwiceDifferentiableFunction,
# Increment the number of steps we've had to perform
iteration += 1

# Search direction is always the negative gradient divided by H
# TODO: Do this calculation in place
@inbounds s[:] = -(H \ gr)
# Search direction is always the negative gradient divided by
# a matrix encoding the absolute values of the curvatures
# represented by H. It deviates from the usual "add a scaled
# identity matrix" version of the modified Newton method. More
# information can be found in the discussion at issue #153.
F, Hd = ldltfact!(Positive, H)
s[:] = -(F\gr)

# Refresh the line search cache
dphi0 = vecdot(gr, s)
Expand Down
7 changes: 7 additions & 0 deletions test/newton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ for (name, prob) in Optim.UnconstrainedProblems.examples
@assert norm(Optim.minimizer(res) - prob.solutions) < 1e-2
end
end

let
prob=Optim.UnconstrainedProblems.examples["Himmelblau"]
ddf = TwiceDifferentiableFunction(prob.f, prob.g!, prob.h!)
res = optimize(ddf, [0., 0.], Newton())
@assert norm(res.minimum - prob.solutions) < 1e-10
end