Skip to content

Erroneous Hessian on second evaluation #24

@dpo

Description

@dpo

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: ", values

Here 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions