<s> """<STR_LIT>""" <EOL> import pkg_resources <EOL> import sys <EOL> import unittest <EOL> import numpy <EOL> from openmdao . main . datatypes . api import Float , Array <EOL> from openmdao . main . api import Component , Assembly , set_as_top <EOL> from openmdao . main . eggchecker import check_save_load <EOL> from openmdao . lib . drivers . conmindriver import CONMINdriver <EOL> from openmdao . util . testutil import assert_rel_error <EOL> class OptGolinskiComponent ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Array ( iotype = '<STR_LIT>' , dtype = numpy . float ) <EOL> result = Float ( <NUM_LIT:0.> , iotype = '<STR_LIT>' ) <EOL> def __init__ ( self ) : <EOL> super ( OptGolinskiComponent , self ) . __init__ ( ) <EOL> self . x = numpy . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , dtype = float ) <EOL> self . opt_objective = <NUM_LIT> <EOL> self . opt_design_vars = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> cf = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . result = ( cf [ <NUM_LIT:0> ] * self . x [ <NUM_LIT:0> ] * self . x [ <NUM_LIT:1> ] * self . x [ <NUM_LIT:1> ] * ( cf [ <NUM_LIT:1> ] * self . x [ <NUM_LIT:2> ] * self . x [ <NUM_LIT:2> ] + cf [ <NUM_LIT:2> ] * self . x [ <NUM_LIT:2> ] - cf [ <NUM_LIT:3> ] ) <EOL> - cf [ <NUM_LIT:4> ] * self . x [ <NUM_LIT:0> ] * ( self . x [ <NUM_LIT:5> ] * self . x [ <NUM_LIT:5> ] + self . x [ <NUM_LIT:6> ] * self . x [ <NUM_LIT:6> ] ) <EOL> + cf [ <NUM_LIT:5> ] * ( self . x [ <NUM_LIT:5> ] * self . x [ <NUM_LIT:5> ] * self . x [ <NUM_LIT:5> ] + self . x [ <NUM_LIT:6> ] * self . x [ <NUM_LIT:6> ] * self . x [ <NUM_LIT:6> ] ) <EOL> + cf [ <NUM_LIT:0> ] * ( self . x [ <NUM_LIT:3> ] * self . x [ <NUM_LIT:5> ] * self . x [ <NUM_LIT:5> ] + self . x [ <NUM_LIT:4> ] * self . x [ <NUM_LIT:6> ] * self . x [ <NUM_LIT:6> ] ) ) <EOL> class GolinskiTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> self . top . add ( '<STR_LIT>' , CONMINdriver ( ) ) <EOL> self . top . add ( '<STR_LIT>' , OptGolinskiComponent ( ) ) <EOL> self . top . driver . workflow . add ( '<STR_LIT>' ) <EOL> self . top . driver . iprint = <NUM_LIT:0> <EOL> self . top . driver . itmax = <NUM_LIT:30> <EOL> def tearDown ( self ) : <EOL> self . top = None <EOL> def getx0 ( self , g11 , g12 ) : <EOL> x00 = self . top . comp . x [ <NUM_LIT:0> ] = max ( <NUM_LIT> / ( g11 * g11 * g12 ) , <EOL> <NUM_LIT> / ( g11 * g11 * g12 * g12 ) , <EOL> <NUM_LIT> * g11 , <EOL> <NUM_LIT> ) <EOL> return x00 <EOL> def getx5 ( self , g11 , g12 , g13 ) : <EOL> A1 = ( ( ( <NUM_LIT> * g13 ) / ( g11 * g12 ) ) ** <NUM_LIT:2> + <NUM_LIT> * <NUM_LIT> ) ** <NUM_LIT:0.5> <EOL> g21 = ( A1 / ( <NUM_LIT> * <NUM_LIT:0.1> ) ) ** ( <NUM_LIT:1.0> / <NUM_LIT> ) <EOL> g22 = ( <NUM_LIT> * g13 * g13 * g13 / ( g11 * g12 ) ) ** <NUM_LIT> <EOL> g23 = <NUM_LIT> <EOL> x05 = max ( g21 , g22 , g23 ) <EOL> return x05 <EOL> def getx6 ( self , g11 , g12 , g14 ) : <EOL> A2 = ( ( ( <NUM_LIT> * g14 ) / ( g11 * g12 ) ) ** <NUM_LIT:2> + <NUM_LIT> * <NUM_LIT> ) ** <NUM_LIT:0.5> <EOL> g31 = ( A2 / ( <NUM_LIT> * <NUM_LIT:0.1> ) ) ** ( <NUM_LIT:1.0> / <NUM_LIT> ) <EOL> g32 = ( <NUM_LIT> * g14 * g14 * g14 / ( g11 * g12 ) ) ** <NUM_LIT> <EOL> g33 = <NUM_LIT> <EOL> x06 = max ( g31 , g32 , g33 ) <EOL> return x06 <EOL> def test_opt1 ( self ) : <EOL> self . top . driver . add_objective ( '<STR_LIT>' ) <EOL> iter = <NUM_LIT:1> <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> while iter < <NUM_LIT:4> : <EOL> g00 = self . top . comp . x [ <NUM_LIT:0> ] <EOL> g11 = self . top . comp . x [ <NUM_LIT:1> ] <EOL> g12 = self . top . comp . x [ <NUM_LIT:2> ] <EOL> g13 = self . top . comp . x [ <NUM_LIT:3> ] <EOL> g14 = self . top . comp . x [ <NUM_LIT:4> ] <EOL> g15 = self . top . comp . x [ <NUM_LIT:5> ] <EOL> g16 = self . top . comp . x [ <NUM_LIT:6> ] <EOL> self . top . comp . set ( '<STR_LIT>' , self . getx0 ( g11 , g12 ) ) <EOL> self . top . comp . set ( '<STR_LIT>' , self . getx5 ( g11 , g12 , g13 ) ) <EOL> self . top . comp . set ( '<STR_LIT>' , self . getx6 ( g11 , g12 , g14 ) ) <EOL> self . top . run ( ) <EOL> iter = iter + <NUM_LIT:1> <EOL> assert_rel_error ( self , self . top . comp . opt_objective , self . top . driver . eval_objective ( ) , <NUM_LIT> ) <EOL> assert_rel_error ( self , self . top . comp . opt_design_vars [ <NUM_LIT:1> ] , self . top . comp . x [ <NUM_LIT:1> ] , <NUM_LIT:0.1> ) <EOL> assert_rel_error ( self , self . top . comp . opt_design_vars [ <NUM_LIT:2> ] , self . top . comp . x [ <NUM_LIT:2> ] , <NUM_LIT> ) <EOL> assert_rel_error ( self , self . top . comp . opt_design_vars [ <NUM_LIT:3> ] , self . top . comp . x [ <NUM_LIT:3> ] , <NUM_LIT> ) <EOL> assert_rel_error ( self , self . top . comp . opt_design_vars [ <NUM_LIT:4> ] , self . top . comp . x [ <NUM_LIT:4> ] , <NUM_LIT> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import nose <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> nose . runmodule ( ) </s>
