<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> import scipy . sparse <EOL> from openmdao . core . component import Component <EOL> from openmdao . core . group import Group <EOL> from openmdao . core . parallel_group import ParallelGroup <EOL> from openmdao . components . indep_var_comp import IndepVarComp <EOL> from openmdao . components . exec_comp import ExecComp <EOL> class SimpleComp ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , multiplier = <NUM_LIT> ) : <EOL> super ( SimpleComp , self ) . __init__ ( ) <EOL> self . multiplier = multiplier <EOL> self . add_param ( '<STR_LIT:x>' , <NUM_LIT> ) <EOL> self . add_output ( '<STR_LIT:y>' , <NUM_LIT> ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT:y>' ] = self . multiplier * params [ '<STR_LIT:x>' ] <EOL> class SimpleCompDerivMatVec ( SimpleComp ) : <EOL> """<STR_LIT>""" <EOL> def apply_linear ( self , params , unknowns , dparams , dunknowns , dresids , <EOL> mode ) : <EOL> """<STR_LIT>""" <EOL> if mode == '<STR_LIT>' : <EOL> dresids [ '<STR_LIT:y>' ] += self . multiplier * dparams [ '<STR_LIT:x>' ] <EOL> elif mode == '<STR_LIT>' : <EOL> dparams [ '<STR_LIT:x>' ] = self . multiplier * dresids [ '<STR_LIT:y>' ] <EOL> class SimpleCompWrongDeriv ( SimpleComp ) : <EOL> """<STR_LIT>""" <EOL> def apply_linear ( self , params , unknowns , dparams , dunknowns , dresids , <EOL> mode ) : <EOL> """<STR_LIT>""" <EOL> if mode == '<STR_LIT>' : <EOL> dresids [ '<STR_LIT:y>' ] += <NUM_LIT:0.0> <EOL> elif mode == '<STR_LIT>' : <EOL> dparams [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> class SimpleArrayComp ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( SimpleArrayComp , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . zeros ( [ <NUM_LIT:2> ] ) ) <EOL> self . add_output ( '<STR_LIT:y>' , np . zeros ( [ <NUM_LIT:2> ] ) ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] = <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] + <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:1> ] <EOL> unknowns [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] = <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] - <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:1> ] <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> J = { } <EOL> J [ ( '<STR_LIT:y>' , '<STR_LIT:x>' ) ] = np . array ( [ [ dy1_dx1 , dy1_dx2 ] , [ dy2_dx1 , dy2_dx2 ] ] ) <EOL> return J <EOL> class DoubleArrayComp ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( DoubleArrayComp , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , np . zeros ( [ <NUM_LIT:2> ] ) ) <EOL> self . add_param ( '<STR_LIT>' , np . zeros ( [ <NUM_LIT:2> ] ) ) <EOL> self . add_output ( '<STR_LIT>' , np . zeros ( [ <NUM_LIT:2> ] ) ) <EOL> self . add_output ( '<STR_LIT>' , np . zeros ( [ <NUM_LIT:2> ] ) ) <EOL> self . JJ = np . array ( [ [ <NUM_LIT:1.0> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ - <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT> , <NUM_LIT:1.0> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT>' ] = self . JJ [ <NUM_LIT:0> : <NUM_LIT:2> , <NUM_LIT:0> : <NUM_LIT:2> ] . dot ( params [ '<STR_LIT>' ] ) + self . JJ [ <NUM_LIT:0> : <NUM_LIT:2> , <NUM_LIT:2> : <NUM_LIT:4> ] . dot ( params [ '<STR_LIT>' ] ) <EOL> unknowns [ '<STR_LIT>' ] = self . JJ [ <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:0> : <NUM_LIT:2> ] . dot ( params [ '<STR_LIT>' ] ) + self . JJ [ <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:2> : <NUM_LIT:4> ] . dot ( params [ '<STR_LIT>' ] ) <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> J = { } <EOL> J [ ( '<STR_LIT>' , '<STR_LIT>' ) ] = self . JJ [ <NUM_LIT:0> : <NUM_LIT:2> , <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> J [ ( '<STR_LIT>' , '<STR_LIT>' ) ] = self . JJ [ <NUM_LIT:0> : <NUM_LIT:2> , <NUM_LIT:2> : <NUM_LIT:4> ] <EOL> J [ ( '<STR_LIT>' , '<STR_LIT>' ) ] = self . JJ [ <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> J [ ( '<STR_LIT>' , '<STR_LIT>' ) ] = self . JJ [ <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:2> : <NUM_LIT:4> ] <EOL> return J <EOL> class ArrayComp2D ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( ArrayComp2D , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> self . add_output ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> x = params [ '<STR_LIT:x>' ] <EOL> y = unknowns [ '<STR_LIT:y>' ] <EOL> y [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = <NUM_LIT> * x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT:1.0> * x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> y [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] = <NUM_LIT> * x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> y [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] = <NUM_LIT> * x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> y [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] = <NUM_LIT:1.0> * x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> unknowns [ '<STR_LIT:y>' ] = y <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> J = { } <EOL> J [ '<STR_LIT:y>' , '<STR_LIT:x>' ] = np . array ( [ [ <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> return J <EOL> class SimpleSparseArrayComp ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( SimpleSparseArrayComp , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . zeros ( [ <NUM_LIT:4> ] ) ) <EOL> self . add_output ( '<STR_LIT:y>' , np . zeros ( [ <NUM_LIT:4> ] ) ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] = <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] + <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:3> ] <EOL> unknowns [ '<STR_LIT:y>' ] [ <NUM_LIT:2> ] = <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:1> ] - <NUM_LIT> * params [ '<STR_LIT:x>' ] [ <NUM_LIT:2> ] <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> data = [ dy1_dx1 , dy1_dx2 , dy2_dx1 , dy2_dx2 ] <EOL> row = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ] <EOL> col = [ <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> J = { } <EOL> J [ ( '<STR_LIT:y>' , '<STR_LIT:x>' ) ] = scipy . sparse . csc_matrix ( ( data , ( row , col ) ) , <EOL> shape = ( <NUM_LIT:4> , <NUM_LIT:4> ) ) <EOL> return J <EOL> class SimpleImplicitComp ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( SimpleImplicitComp , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , <NUM_LIT:0.5> ) <EOL> self . add_output ( '<STR_LIT:y>' , <NUM_LIT:0.0> ) <EOL> self . add_state ( '<STR_LIT:z>' , <NUM_LIT:0.0> ) <EOL> self . maxiter = <NUM_LIT:10> <EOL> self . atol = <NUM_LIT> <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> x = params [ '<STR_LIT:x>' ] <EOL> z = unknowns [ '<STR_LIT:z>' ] <EOL> znew = z <EOL> iter = <NUM_LIT:0> <EOL> eps = <NUM_LIT> <EOL> while iter < self . maxiter and abs ( eps ) > self . atol : <EOL> z = znew <EOL> znew = <NUM_LIT> - x * z <EOL> eps = x * znew + znew - <NUM_LIT> <EOL> unknowns [ '<STR_LIT:z>' ] = znew <EOL> unknowns [ '<STR_LIT:y>' ] = x + <NUM_LIT> * znew <EOL> resids [ '<STR_LIT:z>' ] = eps <EOL> def apply_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> x = params [ '<STR_LIT:x>' ] <EOL> z = unknowns [ '<STR_LIT:z>' ] <EOL> resids [ '<STR_LIT:z>' ] = x * z + z - <NUM_LIT> <EOL> resids [ '<STR_LIT:y>' ] = x + <NUM_LIT> * z - unknowns [ '<STR_LIT:y>' ] <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> J = { } <EOL> J [ ( '<STR_LIT:y>' , '<STR_LIT:x>' ) ] = np . array ( [ <NUM_LIT:1.0> ] ) <EOL> J [ ( '<STR_LIT:y>' , '<STR_LIT:z>' ) ] = np . array ( [ <NUM_LIT> ] ) <EOL> J [ ( '<STR_LIT:z>' , '<STR_LIT:z>' ) ] = np . array ( [ params [ '<STR_LIT:x>' ] + <NUM_LIT:1.0> ] ) <EOL> J [ ( '<STR_LIT:z>' , '<STR_LIT:x>' ) ] = np . array ( [ unknowns [ '<STR_LIT:z>' ] ] ) <EOL> return J <EOL> class SimplePassByObjComp ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( SimplePassByObjComp , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , '<STR_LIT>' ) <EOL> self . add_output ( '<STR_LIT:y>' , '<STR_LIT>' ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT:y>' ] = params [ '<STR_LIT:x>' ] + self . name <EOL> class FanOut ( Group ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( FanOut , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class FanOutGrouped ( Group ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( FanOutGrouped , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub = self . add ( '<STR_LIT>' , ParallelGroup ( ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class FanOut3Grouped ( Group ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( FanOut3Grouped , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub = self . add ( '<STR_LIT>' , ParallelGroup ( ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class FanOutAllGrouped ( Group ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( FanOutAllGrouped , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) ) <EOL> sub1 = self . add ( '<STR_LIT>' , Group ( ) ) <EOL> sub1 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub2 = self . add ( '<STR_LIT>' , Group ( ) ) <EOL> sub2 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub3 = self . add ( '<STR_LIT>' , Group ( ) ) <EOL> sub3 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class FanIn ( Group ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( FanIn , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class FanInGrouped ( Group ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( FanInGrouped , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT:1.0> ) ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT:1.0> ) ) <EOL> sub = self . add ( '<STR_LIT>' , ParallelGroup ( ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> sub . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class RosenSuzuki ( Component ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( RosenSuzuki , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . array ( [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] ) ) <EOL> self . add_output ( '<STR_LIT:g>' , np . array ( [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] ) ) <EOL> self . add_output ( '<STR_LIT:f>' , <NUM_LIT:0.> ) <EOL> self . opt_objective = <NUM_LIT> <EOL> self . opt_design_vars = [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT> , - <NUM_LIT:1.> ] <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> x = params [ '<STR_LIT:x>' ] <EOL> f = ( x [ <NUM_LIT:0> ] ** <NUM_LIT:2> - <NUM_LIT> * x [ <NUM_LIT:0> ] + x [ <NUM_LIT:1> ] ** <NUM_LIT:2> - <NUM_LIT> * x [ <NUM_LIT:1> ] + <EOL> <NUM_LIT> * x [ <NUM_LIT:2> ] ** <NUM_LIT:2> - <NUM_LIT> * x [ <NUM_LIT:2> ] + x [ <NUM_LIT:3> ] ** <NUM_LIT:2> + <NUM_LIT> * x [ <NUM_LIT:3> ] + <NUM_LIT:50> ) <EOL> unknowns [ '<STR_LIT:f>' ] = f <EOL> g = [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] <EOL> g [ <NUM_LIT:0> ] = ( x [ <NUM_LIT:0> ] ** <NUM_LIT:2> + x [ <NUM_LIT:0> ] + x [ <NUM_LIT:1> ] ** <NUM_LIT:2> - x [ <NUM_LIT:1> ] + <EOL> x [ <NUM_LIT:2> ] ** <NUM_LIT:2> + x [ <NUM_LIT:2> ] + x [ <NUM_LIT:3> ] ** <NUM_LIT:2> - x [ <NUM_LIT:3> ] - <NUM_LIT:8> ) <EOL> g [ <NUM_LIT:1> ] = ( x [ <NUM_LIT:0> ] ** <NUM_LIT:2> - x [ <NUM_LIT:0> ] + <NUM_LIT:2> * x [ <NUM_LIT:1> ] ** <NUM_LIT:2> + x [ <NUM_LIT:2> ] ** <NUM_LIT:2> + <EOL> <NUM_LIT:2> * x [ <NUM_LIT:3> ] ** <NUM_LIT:2> - x [ <NUM_LIT:3> ] - <NUM_LIT:10> ) <EOL> g [ <NUM_LIT:2> ] = ( <NUM_LIT:2> * x [ <NUM_LIT:0> ] ** <NUM_LIT:2> + <NUM_LIT:2> * x [ <NUM_LIT:0> ] + x [ <NUM_LIT:1> ] ** <NUM_LIT:2> - x [ <NUM_LIT:1> ] + <EOL> x [ <NUM_LIT:2> ] ** <NUM_LIT:2> - x [ <NUM_LIT:3> ] - <NUM_LIT:5> ) <EOL> unknowns [ '<STR_LIT:g>' ] = np . array ( g ) <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> J = { } <EOL> x = params [ '<STR_LIT:x>' ] <EOL> J [ ( '<STR_LIT:f>' , '<STR_LIT:x>' ) ] = np . array ( [ <EOL> [ <NUM_LIT:2> * x [ <NUM_LIT:0> ] - <NUM_LIT:5> , <NUM_LIT:2> * x [ <NUM_LIT:1> ] - <NUM_LIT:5> , <NUM_LIT:4> * x [ <NUM_LIT:2> ] - <NUM_LIT> , <NUM_LIT:2> * x [ <NUM_LIT:3> ] + <NUM_LIT:7> ] <EOL> ] ) <EOL> J [ ( '<STR_LIT:g>' , '<STR_LIT:x>' ) ] = np . array ( [ <EOL> [ <NUM_LIT:2> * x [ <NUM_LIT:0> ] + <NUM_LIT:1> , <NUM_LIT:2> * x [ <NUM_LIT:1> ] - <NUM_LIT:1> , <NUM_LIT:2> * x [ <NUM_LIT:2> ] + <NUM_LIT:1> , <NUM_LIT:2> * x [ <NUM_LIT:3> ] - <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:2> * x [ <NUM_LIT:0> ] - <NUM_LIT:1> , <NUM_LIT:4> * x [ <NUM_LIT:1> ] , <NUM_LIT:2> * x [ <NUM_LIT:2> ] , <NUM_LIT:4> * x [ <NUM_LIT:3> ] - <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:4> * x [ <NUM_LIT:0> ] + <NUM_LIT:2> , <NUM_LIT:2> * x [ <NUM_LIT:1> ] - <NUM_LIT:1> , <NUM_LIT:2> * x [ <NUM_LIT:2> ] , - <NUM_LIT:1> ] , <EOL> ] ) <EOL> return J </s>
