#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# if ( OPT is None ) : #NEWLINE# #INDENT# raise unittest . SkipTest ( 'pyoptsparse is not installed' ) #NEWLINE# #UNINDENT# if ( OPTIMIZER is None ) : #NEWLINE# #INDENT# raise unittest . SkipTest ( 'pyoptsparse is not providing SNOPT or SLSQP' ) #NEWLINE# #UNINDENT# prob = Problem ( impl = impl ) #NEWLINE# root = prob . root = Group ( ) #NEWLINE# root . ln_solver = LinearGaussSeidel ( ) #NEWLINE# par = root . add ( 'par' , ParallelGroup ( ) ) #NEWLINE# par . ln_solver = LinearGaussSeidel ( ) #NEWLINE# ser1 = par . add ( 'ser1' , Group ( ) ) #NEWLINE# ser1 . ln_solver = LinearGaussSeidel ( ) #NEWLINE# ser1 . add ( 'p1' , IndepVarComp ( 'x' , np . zeros ( [ 2 ] ) ) , promotes = [ 'x' ] ) #NEWLINE# ser1 . add ( 'comp' , SimpleArrayComp ( ) , promotes = [ 'x' , 'y' ] ) #NEWLINE# ser1 . add ( 'con' , ExecComp ( 'c = y - 20.0' , c = np . array ( [ 0.0 , 0.0 ] ) , y = np . array ( [ 0.0 , 0.0 ] ) ) , promotes = [ 'c' , 'y' ] ) #NEWLINE# ser1 . add ( 'obj' , ExecComp ( 'o = y[0]' , y = np . array ( [ 0.0 , 0.0 ] ) ) , promotes = [ 'y' , 'o' ] ) #NEWLINE# ser2 = par . add ( 'ser2' , Group ( ) ) #NEWLINE# ser2 . ln_solver = LinearGaussSeidel ( ) #NEWLINE# ser2 . add ( 'p1' , IndepVarComp ( 'x' , np . zeros ( [ 2 ] ) ) , promotes = [ 'x' ] ) #NEWLINE# ser2 . add ( 'comp' , SimpleArrayComp ( ) , promotes = [ 'x' , 'y' ] ) #NEWLINE# ser2 . add ( 'con' , ExecComp ( 'c = y - 30.0' , c = np . array ( [ 0.0 , 0.0 ] ) , y = np . array ( [ 0.0 , 0.0 ] ) ) , promotes = [ 'c' , 'y' ] ) #NEWLINE# ser2 . add ( 'obj' , ExecComp ( 'o = y[0]' , y = np . array ( [ 0.0 , 0.0 ] ) ) , promotes = [ 'o' , 'y' ] ) #NEWLINE# root . add ( 'total' , ExecComp ( 'obj = x1 + x2' ) ) #NEWLINE# root . connect ( 'par.ser1.o' , 'total.x1' ) #NEWLINE# root . connect ( 'par.ser2.o' , 'total.x2' ) #NEWLINE# prob . driver = pyOptSparseDriver ( ) #NEWLINE# prob . driver . options [ 'optimizer' ] = OPTIMIZER #NEWLINE# prob . driver . options [ 'print_results' ] = False #NEWLINE# prob . driver . add_desvar ( 'par.ser1.x' , lower = ( - 50.0 ) , upper = 50.0 ) #NEWLINE# prob . driver . add_desvar ( 'par.ser2.x' , lower = ( - 50.0 ) , upper = 50.0 ) #NEWLINE# prob . driver . add_objective ( 'total.obj' ) #NEWLINE# prob . driver . add_constraint ( 'par.ser1.c' , equals = 0.0 ) #NEWLINE# prob . driver . add_constraint ( 'par.ser2.c' , equals = 0.0 ) #NEWLINE# self . prob = ser2