-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
I'm having an issue where the first (sparse) Hessian evaluation is correct, but the second is not. I'm not sure if it's an Adol-C issue or a pyadolc issue. I'm using ColPack 1.0.9 and Adol-C 2.6.0 on OSX. Here's a minimum working example:
import adolc
import numpy as np
def rosenbrock(x):
return np.sum(100 * (x[1:] - x[:-1]**2)**2 + (1 - x[:-1])**2)
nvar = 5
x = -np.ones(nvar)
# trace function value
obj_trace_id = 1
adolc.trace_on(obj_trace_id)
ax = adolc.adouble(x)
adolc.independent(ax)
y = rosenbrock(ax)
adolc.dependent(y)
adolc.trace_off()
# evaluate gradient
g = adolc.gradient(obj_trace_id, x)
# evaluate sparse hessian
options = np.zeros(2, dtype=int)
nnz, rind0, cind0, values0 = \
adolc.colpack.sparse_hess_no_repeat(obj_trace_id,
x, options=options)
print "rind: ", rind0
print "cind: ", cind0
print "vals: ", values0
# evaluate sparse hessian again
nnz, rind, cind, values = \
adolc.colpack.sparse_hess_repeat(obj_trace_id,
x,
rind0,
cind0,
values0)
print "rind: ", rind
print "cind: ", cind
print "vals: ", valuesHere is the output I receive:
rind: [0 0 1 1 2 2 3 3 4]
cind: [0 1 1 2 2 3 3 4 4]
vals: [ 1602. 400. 1802. 400. 1802. 400. 1802. 400. 200.]
rind: [0 0 1 1 2 2 3 3 4]
cind: [0 1 1 2 2 3 3 4 4]
vals: [ 1602. 400. 1802. 800. 1802. 800. 1802. 400. 200.]
On the second sparse Hessian evaluation, certain off-diagonals changed. Can you reproduce this issue?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels