How can we specify that a given parameter does not affect the gradient of a component in OpenMDAOv1+? In earlier versions we set missing_deriv_policy = 'assume_zero'
, but that does not seem to exist in new OpenMDAO1+. I think I can just add inputs via super
in the __init__
function rather than include them in params
so that they are invisible to OpenMDAO, or perhaps just return the partial derivatives as 0, but what is the intended/recommended way? I'm sorry if this is in the docs, if it is then I must have missed it.

- 2,437
- 1
- 13
- 15
2 Answers
If you don't want your parameter to affect the gradient and you don't need to connect that parameter to another component, then you should definitely just make it a regular python attribute of your component so that it's invisible to the framework. If you do need to have it connected to another component, then you can set 'pass_by_obj' in the metadata for that variable and it will get passed around by the OpenMDAO data passing system but won't affect the gradient. Unfortunately, 'pass_by_obj' can only be used in serial. It doesn't work yet in MPI.

- 704
- 3
- 8
-
Thanks for the comment on MPI, that is pretty important for our application. – jthomas Oct 27 '15 at 19:48
-
This answer isn't quite complete. There is a third option which is likely the most common solution to the problem, in the event that you have a value that you want included in the optimization but with partial derivative as 0. – Justin Gray Oct 28 '15 at 11:50
-
Just an update on pass_by_obj data passing. It now works in MPI as well as in serial. – Bret Naylor Jan 14 '16 at 17:49
There are three options:
- Make it a python attribute instead of a framework variable.
- Use pass by obj
- Leave it out of the Jacobian
You can use 1 if the value is a constant specific to a component and never needs OpenMDAO to pass it around to anything else. If you do need to pass the information around then I suggest 2 or 3.
If you have a value that you want to pass around, but its not a float or an array of floats (i.e. list or dictionary or even integer array), then you would use option 2. OpenMDAO will pass the data around for you, but for the purposes of optimization it will be completely ignored.
If, however, you have a value that is a float or an array of floats, and you want it considered in the optimization then you should use option 3. This is likely to be the most common situation! Perhaps you have a parameter that just doesn't affect one of your outputs in a component, but it affects others. In this case, when you're building the partial derivatives dictionary, you simply leave out the key pairs that you want to be zero. OpenMDAO understands that any derivatives not defined are implied to be zero.
So if you have a function, f(x,y,z) = 3*x + 2*y
, so that z has no impact on it, you would define the jacobian as follows:
J = {}
J['f','x'] = 3
J['f','y'] = 2
By leaving out the ('f','z')
partial derivative i've told OpenMDAO that it is zero.

- 5,605
- 1
- 11
- 16
-
Thank you very much for your answer. This further explanation completely changes how we will pass things. It sounds like the combination of these will work very well for us. We will almost certainly use all three methods. – jthomas Oct 28 '15 at 16:47