Scaled Paraboloid And Derivatives Checking
Solution 1:
relf
So, you have encountered a limitation that has come up before, namely you can't calculate derivatives about a design point until you run your model at that point. The finite difference results are wrong because the model has never been run. To verify your partials, you need to move check_partial_derivatives
to after the run. Also, I always comment out the optimizer when I am checking derivatives so that I am checking derivatives about the initial point. When I did these two things, I got good results (see code below).
top = Problem()
root = top.root = Group()
#root.fd_options['force_fd'] = True
root.add('p1', IndepVarComp('x', 3.0))
root.add('p2', IndepVarComp('y', -4.0))
root.add('p', Paraboloid())
root.connect('p1.x', 'p.x')
root.connect('p2.y', 'p.y')
#top.driver = ScipyOptimizer()
#top.driver.options['optimizer'] = 'SLSQP'
#top.driver.add_desvar('p1.x', lower=-1000, upper=1000, scaler=1000.)
#top.driver.add_desvar('p2.y', lower=-1000, upper=1000, scaler=0.001)
#top.driver.add_objective('p.f_xy')
top.setup()
top.run()
top.check_partial_derivatives() # added line
print('\n')
print('Minimum of %f found at (%f, %f)' % (top['p.f_xy'], top['p.x'], top['p.y']))
There is a feature request on our github for the ability to run check_partial_derivatives without running the model first. I think it is feasible that we will can do this by just telling root to solve_nonlinear, ignoring the driver, so it will probably be added at some point.
Post a Comment for "Scaled Paraboloid And Derivatives Checking"