How to tie SNOPT jacobian row and column back to OpenMDAO objective / constraint and variable

51 Views Asked by At

I am doing some debugging on a problem in OpenMDAO. I am using SNOPT as my optimizer. With SNOPT, you can do a derivatives check on your problem with the option "Verify level = 2". This will check your problem partial derivatives with finite difference, from what I understand. It will print the results of these to SNOPT_print.out.

In this print out, the headings

"Column" "x(j)" "dx(j)" "Element no." "Row" "Derivative" "Difference approxn"

appear.

Now, SNOPT thinks something is wrong with one of my derivatives is wrong. The text "bad?"

appears next to the "Difference approxn" column. Sorry I'm not copy pasting directly the output, but I don't have access to it at the moment.

I would like to know the column and row number map to in my OpenMDAO problem, to see I if I can find out just what the matter is. It definitely looks like a sign flip as the Derivative provided to SNOPT and finite diff approximation equal but for the factor of -1.

I have used check_partials() on all my components, but I cannot find the mistake they all seem fine.

I am hoping that I can do some more checking by find exactly what SNOPT is complaining about. Is there some way to interrogate OpenMDAO or pyoptsparse to find out?

2

There are 2 best solutions below

2
Bret Naylor On BEST ANSWER

I would suggest using check_totals. That will at least tell you which design var / response combination has the issue and you may be able to narrow it down from there.

0
Mark Garnett On

Answering my own question on SNOPT derivatives check output: column number corresponds to a design variable, as you'd expect for a Jacobian, and the number corresponds to the pyoptsparse printout index

Objectives Index Name Value 0 traj.phase0.states:x -2.500000E-01

Variables (c - continuous, i - integer, d - discrete) Index Name Type Lower Bound Value Upper Bound Status 0 traj.phase0.states:v_0 c -1.000000E+21 1.183503E-02 1.000000E+21
1 traj.phase0.states:v_1 c -1.000000E+21 2.816497E-02 1.000000E+21
2 traj.phase0.states:v_2 c -1.000000E+21 3.333333E-02 1.000000E+21
3 traj.phase0.states:v_3 c -1.000000E+21 3.333333E-02 1.000000E+21
4 traj.phase0.states:v_4 c -1.000000E+21 4.516837E-02 1.000000E+21

The row number corresponds to pyoptsparse printout of constraints, although the SNOPT row number differs by one from the pyoptsparse printout, because I am guessing the first row of the SNOPT jacobian is the objective

Constraints (i - inequality, e - equality) Index Name Type Lower Value Upper Status Lagrange Multiplier (N/A) 0 traj.phase0.collocation_constraint.defects:v e 0.000000E+00 -7.401487E-18 0.000000E+00 9.00000E+100 1 traj.phase0.collocation_constraint.defects:v e 0.000000E+00 -1.850372E-18 0.000000E+00 9.00000E+100