Getting Started

Installation Instructions:

Use git to clone the repository:

git clone http://github.com/OpenMDAO/blue

Use pip to install openmdao locally:

cd blue

pip install .

Hello world!

Here is a really short run file to get you started running your first optimization. Copy the code into a file named hello_world.py and run it by typing:

python hello_world.py
from openmdao.api import Problem, ScipyOptimizer, ExecComp, IndepVarComp

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

prob.model.add_subsystem('paraboloid', 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 = ScipyOptimizer()
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)
prob.model.add_objective('paraboloid.f')

prob.setup()
prob.run_driver()
Optimization terminated successfully.    (Exit mode 0)
            Current function value: [-27.33333333]
            Iterations: 5
            Function evaluations: 6
            Gradient evaluations: 5
Optimization Complete
-----------------------------------
# minimum value
print(prob['paraboloid.f'])
[-27.33333333]
# location of the minimum
print(prob['indeps.x'])
[ 6.66666667]
print(prob['indeps.y'])
[-7.33333333]