Getting Started

Installation Instructions:

From your python environment (we recommend Anaconda), just type:

>> pip install openmdao[all]


The [all] suffix to the install command ensures that you get all the optional dependencies (e.g. for testing and visualization). You can omit this for a minimal installation.

Sample Optimization File

With OpenMDAO installed, let’s try out a simple example, to get you started running your first optimization. Copy the following code into a file named

import openmdao.api as om

# build the model
prob = om.Problem()
indeps = prob.model.add_subsystem('indeps', om.IndepVarComp())
indeps.add_output('x', 3.0)
indeps.add_output('y', -4.0)

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

prob.model.connect('indeps.x', 'paraboloid.x')
prob.model.connect('indeps.y', 'paraboloid.y')

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

prob.model.add_design_var('indeps.x', lower=-50, upper=50)
prob.model.add_design_var('indeps.y', lower=-50, upper=50)


# minimum value

# location of the minimum

Then, to run the file, simply type:

>> python

If all works as planned, results should appear as such:

Optimization terminated successfully.    (Exit mode 0)
            Current function value: -27.33333333333333
            Iterations: 5
            Function evaluations: 6
            Gradient evaluations: 5
Optimization Complete