Last active
August 29, 2015 14:19
-
-
Save AndyGreenwell/5be0cd5fa67d79990e36 to your computer and use it in GitHub Desktop.
Test case for triggering "ERROR: UndefVarError: Error not defined" in secant2! of hz_linesearch.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module OptimTest | |
using Optim, Hadamard | |
function symcond(n,κ) | |
Q = hadamard(n) | |
D = diagm(exp(linspace(0,-log(κ),n))); | |
Q*D*Q'/n | |
end | |
A = symcond(12,1e14) | |
temp = 1.0 + 1e-14*rand() | |
function c(x) | |
c = dot(x,A*x)/2 | |
#println("No op") | |
end | |
function g!(x,grad::Vector) | |
grad[:] = (A*x).*temp | |
#println("No op") | |
end | |
function cg!(x,grad::Vector) | |
#A = symcond(12,1e14) | |
c = dot(x,A*x)/2 # cost function | |
#temp = 1.0 + 1e-14*rand() | |
#println("temp = $temp") | |
grad[:] = (A*x).*temp # gradient | |
return c | |
end | |
function driver() | |
df = DifferentiableFunction(c,g!,cg!) | |
inputvec = randn(12) | |
println("inputvec = $inputvec") | |
@time optim_output = Optim.optimize(df, inputvec, method = :l_bfgs, iterations = 10000, ftol=1e-6, grtol=1e-12, show_trace = false) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment