<s> from openmdao . main . api import Assembly , Component , set_as_top <EOL> from openmdao . lib . datatypes . api import Float <EOL> from pyopt_driver . pyopt_driver import pyOptDriver <EOL> class Rosenbrock ( Component ) : <EOL> """<STR_LIT>""" <EOL> x1 = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , low = <NUM_LIT:0.0> , high = <NUM_LIT> , start = <NUM_LIT> ) <EOL> x2 = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> , start = <NUM_LIT> ) <EOL> f = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . f = ( <NUM_LIT:1> - self . x1 ) ** <NUM_LIT:2> + <NUM_LIT:100> * ( self . x2 - self . x1 ** <NUM_LIT:2> ) ** <NUM_LIT:2> <EOL> class RBOpt ( Assembly ) : <EOL> """<STR_LIT>""" <EOL> output = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> def configure ( self ) : <EOL> self . add ( '<STR_LIT>' , Rosenbrock ( ) ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . add ( '<STR_LIT>' , pyOptDriver ( ) ) <EOL> self . driver . optimizer = '<STR_LIT>' <EOL> self . driver . options = { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } <EOL> self . driver . add_objective ( '<STR_LIT>' ) <EOL> self . driver . add_parameter ( '<STR_LIT>' ) <EOL> self . driver . add_parameter ( '<STR_LIT>' ) <EOL> self . driver . add_constraint ( '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import sys <EOL> import time <EOL> prob = set_as_top ( RBOpt ( ) ) <EOL> tt = time . time ( ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> import cProfile <EOL> import pstats <EOL> cProfile . run ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> p = pstats . Stats ( '<STR_LIT>' ) <EOL> p . strip_dirs ( ) <EOL> p . sort_stats ( '<STR_LIT>' , '<STR_LIT:time>' ) <EOL> p . print_stats ( ) <EOL> print '<STR_LIT>' <EOL> p . sort_stats ( '<STR_LIT>' , '<STR_LIT:time>' ) <EOL> p . print_stats ( ) <EOL> print '<STR_LIT>' <EOL> p . print_callers ( ) <EOL> print '<STR_LIT>' <EOL> p . print_callees ( ) <EOL> else : <EOL> prob . run ( ) <EOL> print prob . func . x1 , prob . func . x2 <EOL> print "<STR_LIT>" , time . time ( ) - tt , "<STR_LIT>" <EOL> print "<STR_LIT>" , prob . func . exec_count </s>
