Search code examples
pythonopenmdao

RuntimeError: Group (<model>): Output not found for design variable 'paraboloid.x'


I have been trying to run openmdao on my mac. Openmdao seems to be installed along with mpi4py but the code doesn't seem to be working. I have been getting the following error "RuntimeError: Group (): Output not found for design variable 'paraboloid.x'." The following is the code. This code is the example code provided in the openmdao get started page. Please help!

import openmdao.api as om

# build the model
prob = om.Problem()

prob.model.add_subsystem('paraboloid', om.ExecComp('f = (x-3)**2 + x*y + (y+4)**2 - 3'))

# setup the optimization
prob.driver = om.ScipyOptimizeDriver()
prob.driver.options['optimizer'] = 'SLSQP'

prob.model.add_design_var('paraboloid.x', lower=-50, upper=50)
prob.model.add_design_var('paraboloid.y', lower=-50, upper=50)
prob.model.add_objective('paraboloid.f')

prob.setup()

# Set initial values.
prob.set_val('paraboloid.x', 3.0)
prob.set_val('paraboloid.y', -4.0)

# run the optimization
prob.run_driver()

# minimum value
print(prob.get_val('paraboloid.f'))

# location of the minimum
print(prob.get_val('paraboloid.x'))
print(prob.get_val('paraboloid.y'))

Solution

  • This code works only with OpenMDAO >= 3.2 (auto ivc feature). Check your version with the command openmdao --version. Otherwise you have to add IndepVarComp declarations (see Conversion Guide for the Auto-IVC (IndepVarComp) Feature).