'Functions scaling in OpenMDAO
Is there any way to apply a logarithmic scaling to the design objectives/constraints in OpenMDAO? In my optimization problem, I have to deal with an objective function that takes large values and varies significantly over the design space (between the orders 10^6 and 10^7), so I would ideally like to make the driver handle the log of the objective. I have modified my objective function directly for now, but it would be more convenient to do it at the driver level. Is that possible?
Solution 1:[1]
Currently openmdao drivers don't support nonlinear scaling, and doing so through a component is the correct approach. In the past I've sometimes made a separate "objective" component that exists to apply some transformation to the raw objective. That allows you to drop it into your model when necessary without the need to change the original calculations.
Solution 2:[2]
A middle ground between "modify the component" and "have OpenMDAO driver api do it for you" is to use an ExecComp.
prob.model.add_subsystem('log_scale', om.ExecComp('log_f = log(f)')
prob.model.connect('some_comp.f', 'log_scale.f')
prob.driver.add_objective('log_scale.log_f')
The exec-comp will handle the derivatives of that transformation for you. All you have to do is connect your objective into the right input on the ExecComp instance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rob Falck |
| Solution 2 |
