Reputation: 350
I am trying to access to the derivatives. Looking at the manual, the recorder should have it. However, running the below code i receive the error : Any idea?
deriv_case = cr.driver_derivative_cases.get_case('rank0:SLSQP|1')
AttributeError: 'SqliteCaseReader' object has no attribute 'driver_derivative_cases'**
from openmdao.drivers.scipy_optimizer import ScipyOptimizeDriver
from openmdao.test_suite.components.sellar import SellarDerivativesGrouped
from openmdao.test_suite.components.sellar import SellarProblem
from openmdao.recorders.case_reader import CaseReader
from openmdao.recorders.sqlite_recorder import SqliteRecorder
prob = SellarProblem(SellarDerivativesGrouped)
driver = prob.driver = ScipyOptimizeDriver(optimizer='SLSQP')
driver.recording_options['record_derivatives'] = True
fname = "record.sql"
recorder = SqliteRecorder(fname)
prob.driver.add_recorder(recorder)
#driver.add_recorder('recorder')
prob.setup()
prob.run_driver()
prob.cleanup()
cr = CaseReader(fname)
# Get derivatives associated with the first iteration.
deriv_case = cr.driver_derivative_cases.get_case('rank0:SLSQP|1')
# Get all derivatives from that case.
derivs = deriv_case.get_derivatives()
# See what derivatives have been recorded.
print(set(derivs.keys))
Upvotes: 0
Views: 41
Reputation: 2202
That example comes from the latest beta docs, which are associated with the current code on the github master branch. I gather you are probably running the most recent release, which is 2.3.1, which doesn't have that feature yet. You could either clone our repo on Github to get the most recent commits to the code, or you could wait until we release 2.4.
Upvotes: 1