#NEWLINE# def test_scaler_adder_int( self ) : #NEWLINE# #INDENT# prob = Problem ( ) #NEWLINE# root = prob . root = Group ( ) #NEWLINE# driver = prob . driver = ScaleAddDriver ( ) #NEWLINE# root . add ( 'p1' , IndepVarComp ( [ ( 'x' , 12.0 , { #NEWLINE# #INDENT# 'desc' : 'my x' , #NEWLINE# #UNINDENT# } ) , ( 'y' , 13.0 , { #NEWLINE# #INDENT# 'desc' : 'my y' , #NEWLINE# #UNINDENT# } ) ] ) , promotes = [ '*' ] ) #NEWLINE# root . add ( 'comp' , Paraboloid ( ) , promotes = [ '*' ] ) #NEWLINE# root . add ( 'constraint' , ExecComp ( 'con=f_xy + x + y' ) , promotes = [ '*' ] ) #NEWLINE# driver . add_desvar ( 'x' , adder = ( - 10 ) , scaler = 20.0 ) #NEWLINE# driver . add_objective ( 'f_xy' , adder = ( - 10 ) , scaler = 20 ) #NEWLINE# driver . add_constraint ( 'con' , upper = 0 , adder = ( - 10 ) , scaler = 20 ) #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# self . assertEqual ( driver . param , 40.0 ) #NEWLINE# self . assertEqual ( prob [ 'x' ] , 10.025 ) #NEWLINE# assert_rel_error ( self , driver . obj_scaled [ 0 ] , 9113.5125 , 1e-06 ) #NEWLINE# assert_rel_error ( self , driver . con_scaled [ 0 ] , 9574.0125 , 1e-06 ) #NEWLINE# J = driver . calc_gradient ( [ 'x' , 'y' ] , [ 'f_xy' ] ) #NEWLINE# assert_rel_error ( self , J [ 0 ] [ 0 ] , 27.05 , 1e-06 ) #NEWLINE# assert_rel_error ( self , J [ 0 ] [ 1 ] , 880.5 , 1e-06 )