Ejemplo n.º 1
0
    def configure(self):
        super(hyperTop, self).configure()
        #--------------------------Component Setup-----------------------------------

        self.add('NPSS', DesignCase())  #imported from npssCases.py

        #---------------------------DOE Setup----------------------------------------
        self.add('driver', DOEdriver())
        self.driver.add_parameter('NPSS.tube_Pt', low=99.0 / 0.5282,
                                  high=300.)  #low=1760., high=1960.)
        self.driver.add_parameter('NPSS.capsule_MN', low=0.6,
                                  high=1.)  #low=1760., high=1960.)
        self.driver.add_parameter('NPSS.bearing_Pt', low=11000.,
                                  high=12000.)  #low=1760., high=1960.)

        self.driver.DOEgenerator = FullFactorial(num_levels=1)

        #------------------------Case Recorders Setup--------------------------------
        #outfile = open('test_jeff.txt','w')
        #self.driver.recorders = [CSVCaseRecorder(filename='DOEoutdata.csv'), DumpCaseRecorder(outfile)]
        ##other options DBCase,ListCaseRecorder

        #self.driver.printvars = ['designInputs.*']
        #self.driver.recorders[0].num_backups = 0   #save backup copies of previous runs (dated)

        #-------------------------- Assembly Setup ----------------------------------
        # Assembly Workflow
        self.driver.workflow.add(['NPSS'])  #
 def configure(self):
     self.add('d', Dummy())
     self.add('driver', NeighborhoodDOEdriver())
     self.driver.DOEgenerator = FullFactorial(2)
     self.driver.recorders = [DumpCaseRecorder()]
     self.driver.add_parameter('d.x', low=0, high=10)
     self.driver.case_outputs = ['d.y', 'd.bad', 'd.z']
Ejemplo n.º 3
0
 def __init__(self):
     super(Simulation,self).__init__()
 
     #Components
     self.add("sin_meta_model",MetaModel())      
     self.sin_meta_model.surrogate = {"default":KrigingSurrogate()}  
     self.sin_meta_model.model = Sin()        
     self.sin_meta_model.recorder = DBCaseRecorder()
     
     #Training the MetaModel
     self.add("DOE_Trainer",DOEdriver())
     self.DOE_Trainer.DOEgenerator = FullFactorial()
     self.DOE_Trainer.DOEgenerator.num_levels = 25
     self.DOE_Trainer.add_parameter("sin_meta_model.x",low=0,high=20)
     self.DOE_Trainer.case_outputs = ["sin_meta_model.f_x"]
     self.DOE_Trainer.add_event("sin_meta_model.train_next")
     self.DOE_Trainer.recorders = [DBCaseRecorder()]
     self.DOE_Trainer.force_execute = True
     
     #MetaModel Validation
     self.add("sin_calc",Sin())
     self.add("DOE_Validate",DOEdriver())
     self.DOE_Validate.DOEgenerator = Uniform()
     self.DOE_Validate.DOEgenerator.num_samples = 100
     self.DOE_Validate.add_parameter(("sin_meta_model.x","sin_calc.x"),low=0,high=20)
     self.DOE_Validate.case_outputs = ["sin_calc.f_x","sin_meta_model.f_x"]
     self.DOE_Validate.recorders = [DBCaseRecorder()]
     self.DOE_Validate.force_execute = True
     
     #Iteration Hierarchy
     self.driver.workflow = SequentialWorkflow()
     self.driver.workflow.add(['DOE_Trainer','DOE_Validate'])
     self.DOE_Trainer.workflow.add('sin_meta_model')
     self.DOE_Validate.workflow.add('sin_meta_model')
     self.DOE_Validate.workflow.add('sin_calc')
    def configure(self):
        # Components
        self.add("sin_meta_model", MetaModel())
        self.sin_meta_model.model = Sin()
        self.sin_meta_model.default_surrogate = FloatKrigingSurrogate()

        # Training the MetaModel
        self.add("DOE_Trainer", DOEdriver())
        self.DOE_Trainer.DOEgenerator = FullFactorial()
        self.DOE_Trainer.DOEgenerator.num_levels = 25
        self.DOE_Trainer.add_parameter("sin_meta_model.x", low=0, high=20)
        self.DOE_Trainer.case_outputs = ["sin_meta_model.f_x"]
        self.DOE_Trainer.add_event("sin_meta_model.train_next")
        self.DOE_Trainer.recorders = [DBCaseRecorder()]

        # MetaModel Validation
        self.add("sin_calc", Sin())
        self.add("DOE_Validate", DOEdriver())
        self.DOE_Validate.DOEgenerator = Uniform()
        self.DOE_Validate.DOEgenerator.num_samples = 200
        self.DOE_Validate.add_parameter(("sin_meta_model.x", "sin_calc.x"), low=0, high=20)
        self.DOE_Validate.case_outputs = ["sin_calc.f_x", "sin_meta_model.f_x"]
        self.DOE_Validate.recorders = [DBCaseRecorder()]

        # Iteration Hierarchy
        self.driver.workflow = SequentialWorkflow()
        self.driver.workflow.add(['DOE_Trainer', 'DOE_Validate'])
        self.DOE_Trainer.workflow.add('sin_meta_model')
        self.DOE_Validate.workflow.add('sin_meta_model')
        self.DOE_Validate.workflow.add('sin_calc')
Ejemplo n.º 5
0
    def configure(self):
        comp = self.add('comp', Comp())

        doe = self.add('doe', NeighborhoodDOEdriver())
        doe.DOEgenerator = FullFactorial()
        doe.alpha = .1
        doe.add_parameter('comp.x')
        doe.add_response('comp.y')
        doe.workflow.add('comp')

        meta = self.add('meta', MetaModel(params=('x', ), responses=('y', )))
        meta.default_surrogate = ResponseSurface()

        self.connect('doe.case_inputs.comp.x', 'meta.params.x')
        self.connect('doe.case_outputs.comp.y', 'meta.responses.y')

        opt = self.add('opt', SLSQPdriver())
        opt.add_parameter('meta.x', high=10., low=-10.)
        opt.add_objective('meta.y')
        opt.workflow.add('meta')

        drv = self.add('driver', FixedPointIterator())
        drv.max_iteration = 2
        drv.add_parameter('y')
        drv.add_constraint('y=meta.y')
        drv.workflow.add(['doe', 'opt'])
Ejemplo n.º 6
0
 def configure(self):
     self.add('driver', DOEdriver())
     self.add('driven', ComponentWhichRaisesException())
     self.driver.workflow.add('driven')
     self.driver.error_policy = 'RETRY'
     self.driver.DOEgenerator = FullFactorial(2)
     self.driver.add_parameter('driven.x', low=-50, high=50)
     self.driver.add_response('driven.f_x')
Ejemplo n.º 7
0
    def configure(self):
        self.add('driver', IterateUntil())
        self.add('adaptive', AdaptiveSampleDriver())
        self.add('driven', DrivenComponent())
        self.driver.workflow.add('adaptive')
        self.adaptive.workflow.add('driven')
        self.adaptive.DOEgenerator = FullFactorial()
        self.adaptive.DOEgenerator.num_levels = 2
        self.adaptive.add_parameter('driven.x', low=-10., high=10.)
        self.adaptive.add_response('driven.y')

        self.adaptive.record_doe = False
Ejemplo n.º 8
0
    def test_AutoBEM_DOE(self):
        # perform a DOE
        self.top.replace('driver', DOEdriver())
        self.top.driver.DOEgenerator = FullFactorial(3)

        self.top.driver.add_parameter('b.chord_hub', low=.1, high=2)
        self.top.driver.add_parameter('b.chord_tip', low=.1, high=2)
        self.top.driver.add_parameter('b.rpm', low=20, high=300)
        self.top.driver.add_parameter('b.twist_hub', low=-5, high=50)
        self.top.driver.add_parameter('b.twist_tip', low=-5, high=50)

        self.top.run()

        self.assertEqual(self.top.b.exec_count, 243)
Ejemplo n.º 9
0
    def configure(self):

        # Our component to be meta-modeled
        self.add("trig_calc", Trig())

        # Create meta_model for two responsese
        self.add("trig_meta_model",
                 MetaModel(params=('x', ), responses=('f_x_sin', 'f_x_cos')))

        # Use Kriging for the f_x output
        self.trig_meta_model.surrogates['f_x_sin'] = LogisticRegression()
        self.trig_meta_model.surrogates['f_x_cos'] = FloatKrigingSurrogate()

        # Training the MetaModel
        self.add("DOE_Trainer", DOEdriver())
        self.DOE_Trainer.DOEgenerator = FullFactorial()
        self.DOE_Trainer.DOEgenerator.num_levels = 20
        self.DOE_Trainer.add_parameter("trig_calc.x", low=0, high=20)
        self.DOE_Trainer.add_response('trig_calc.f_x_sin')
        self.DOE_Trainer.add_response('trig_calc.f_x_cos')

        # Pass training data to the meta model.
        self.connect('DOE_Trainer.case_inputs.trig_calc.x',
                     'trig_meta_model.params.x')
        self.connect('DOE_Trainer.case_outputs.trig_calc.f_x_sin',
                     'trig_meta_model.responses.f_x_sin')
        self.connect('DOE_Trainer.case_outputs.trig_calc.f_x_cos',
                     'trig_meta_model.responses.f_x_cos')

        #MetaModel Validation
        self.add("DOE_Validate", DOEdriver())
        self.DOE_Validate.DOEgenerator = Uniform()
        self.DOE_Validate.DOEgenerator.num_samples = 20
        self.DOE_Validate.add_parameter(("trig_meta_model.x", "trig_calc.x"),
                                        low=0,
                                        high=20)
        self.DOE_Validate.add_response("trig_calc.f_x_sin")
        self.DOE_Validate.add_response("trig_calc.f_x_cos")
        self.DOE_Validate.add_response("trig_meta_model.f_x_sin")
        self.DOE_Validate.add_response("trig_meta_model.f_x_cos")

        #Iteration Hierarchy
        self.driver.workflow.add(['DOE_Trainer', 'DOE_Validate'])
        self.DOE_Trainer.workflow.add('trig_calc')
        self.DOE_Validate.workflow.add(['trig_calc', 'trig_meta_model'])
Ejemplo n.º 10
0
    def configure(self):
        """ Configure a simple DOE to set start points for CONMIN. """
        self.add('gp_fun', GoldsteinPrice())

        conmin = self.add('conmin', CONMINdriver())
        conmin.workflow.add('gp_fun')
        conmin.add_parameter('gp_fun.x1')
        conmin.add_parameter('gp_fun.x2')
        conmin.add_objective('gp_fun.f')

        doe = self.add('driver', DOEdriver())
        doe.workflow.add('conmin')
        doe.add_parameter('gp_fun.x1', low=-1.5, high=1.5, start=1)
        doe.add_parameter('gp_fun.x2', low=-1.5, high=1.5, start=1)
        doe.DOEgenerator = FullFactorial(5)
        doe.add_responses(
            ['gp_fun.f', 'gp_fun.x1', 'gp_fun.x2', 'gp_fun.exec_count'])
        self.recorders = [CSVCaseRecorder(), DumpCaseRecorder()]
Ejemplo n.º 11
0
 def configure(self):
     
     self.add('paraboloid',Paraboloid())
     
     self.add('driver',DOEdriver())
     #There are a number of different kinds of DOE available in openmdao.lib.doegenerators
     self.driver.DOEgenerator = FullFactorial(10) #Full Factorial DOE with 10 levels for each variable
     
     #DOEdriver will automatically record the values of any parameters for each case
     self.driver.add_parameter('paraboloid.x',low=-50,high=50)
     self.driver.add_parameter('paraboloid.y',low=-50,high=50)
     #tell the DOEdriver to also record any other variables you want to know for each case
     self.driver.case_outputs = ['paraboloid.f_xy',]
     
     #Simple recorder which stores the cases in memory. 
     self.driver.recorders = [ListCaseRecorder(),]
     
     self.driver.workflow.add('paraboloid')
Ejemplo n.º 12
0
    def test_AutoBEM_DOE(self):
        # perform a DOE
        self.top.replace('driver', DOEdriver())
        self.top.driver.DOEgenerator = FullFactorial(3)
        self.top.driver.recorders = [ListCaseRecorder()]
        self.top.driver.case_outputs = [
            'b.perf.data.tip_speed_ratio', 'b.perf.data.Cp', 'b.perf.data.Ct'
        ]

        self.top.driver.add_parameter('b.chord_hub', low=.1, high=2)
        self.top.driver.add_parameter('b.chord_tip', low=.1, high=2)
        self.top.driver.add_parameter('b.rpm', low=20, high=300)
        self.top.driver.add_parameter('b.twist_hub', low=-5, high=50)
        self.top.driver.add_parameter('b.twist_tip', low=-5, high=50)

        self.top.run()

        self.assertEqual(len(self.top.driver.recorders[0]), 243)
Ejemplo n.º 13
0
    def configure(self):
        self.add("driver", DOEdriver())
        self.recorders = [ListCaseRecorder()]
        self.driver.DOEgenerator = FullFactorial()
        # configure the specific DOE options
        self.driver.DOEgenerator.num_levels = 3

        self.add("dis1", sellar.Discipline1())
        self.add("dis2", sellar.Discipline2())

        # setting some variables to fixed values
        self.dis1.y2 = 3.15
        self.dis2.y1 = 3.78

        # adding three parameters to the DOEDriver
        self.driver.add_parameter(("dis1.z1", "dis2.z1"), low=-10.0, high=10.0)
        self.driver.add_parameter(("dis1.z2", "dis2.z2"), low=0.0, high=10.0)
        self.driver.add_parameter("dis1.x1", low=0.0, high=10.0)
Ejemplo n.º 14
0
    def configure(self):

        # Our component to be meta-modeled
        self.add("sin_calc", Sin())

        # Another instance of our component for head-to-head comparison with
        # the metamodel.
        self.add("sin_verify", Sin())

        # Create meta_model for f_x as the response
        self.add("sin_meta_model",
                 MetaModel(params=('x', ), responses=('f_x', )))

        # Use Kriging for the f_x output
        self.sin_meta_model.default_surrogate = FloatKrigingSurrogate()

        # Training the MetaModel
        self.add("DOE_Trainer", DOEdriver())
        self.DOE_Trainer.DOEgenerator = FullFactorial()
        self.DOE_Trainer.DOEgenerator.num_levels = 25
        self.DOE_Trainer.add_parameter("sin_calc.x", low=0, high=20)
        self.DOE_Trainer.add_response('sin_calc.f_x')

        # Pass training data to the meta model.
        self.connect('DOE_Trainer.case_inputs.sin_calc.x',
                     'sin_meta_model.params.x')
        self.connect('DOE_Trainer.case_outputs.sin_calc.f_x',
                     'sin_meta_model.responses.f_x')

        # Cross-validate the metamodel using random data
        self.add("DOE_Validate", DOEdriver())
        self.DOE_Validate.DOEgenerator = Uniform()
        self.DOE_Validate.DOEgenerator.num_samples = 100
        self.DOE_Validate.add_parameter(("sin_meta_model.x", "sin_verify.x"),
                                        low=0,
                                        high=20)  # , name="combined_input"
        self.DOE_Validate.add_response("sin_verify.f_x")
        self.DOE_Validate.add_response("sin_meta_model.f_x")

        #Iteration Hierarchy
        self.driver.workflow.add(['DOE_Trainer', 'DOE_Validate'])
        self.DOE_Trainer.workflow.add('sin_calc')
        self.DOE_Validate.workflow.add(['sin_verify', 'sin_meta_model'])
Ejemplo n.º 15
0
    def configure(self):

        #Components
        self.add("trig_meta_model", MetaModel())
        self.trig_meta_model.surrogate = {
            "f_x_sin": LogisticRegression(),
            "f_x_cos": KrigingSurrogate()
        }
        self.trig_meta_model.model = Trig()
        self.trig_meta_model.recorder = DBCaseRecorder()

        #Training the MetaModel
        self.add("DOE_Trainer", DOEdriver())
        self.DOE_Trainer.DOEgenerator = FullFactorial()
        self.DOE_Trainer.DOEgenerator.num_levels = 20
        self.DOE_Trainer.add_parameter("trig_meta_model.x", low=0, high=20)
        self.DOE_Trainer.case_outputs = [
            "trig_meta_model.f_x_sin", "trig_meta_model.f_x_cos"
        ]
        self.DOE_Trainer.add_event("trig_meta_model.train_next")
        self.DOE_Trainer.recorders = [DBCaseRecorder()]

        #MetaModel Validation
        self.add("trig_calc", Trig())
        self.add("DOE_Validate", DOEdriver())
        self.DOE_Validate.DOEgenerator = Uniform()
        self.DOE_Validate.DOEgenerator.num_samples = 20
        self.DOE_Validate.add_parameter(("trig_meta_model.x", "trig_calc.x"),
                                        low=0,
                                        high=20)
        self.DOE_Validate.case_outputs = [
            "trig_calc.f_x_sin", "trig_calc.f_x_cos",
            "trig_meta_model.f_x_sin", "trig_meta_model.f_x_cos"
        ]
        self.DOE_Validate.recorders = [DBCaseRecorder()]

        #Iteration Hierarchy
        self.driver.workflow = SequentialWorkflow()
        self.driver.workflow.add(['DOE_Trainer', 'DOE_Validate'])
        self.DOE_Trainer.workflow.add('trig_meta_model')
        self.DOE_Validate.workflow.add('trig_meta_model')
        self.DOE_Validate.workflow.add('trig_calc')
Ejemplo n.º 16
0
    def __init__(self):
        super(Simulation, self).__init__()

        #Components
        self.add("sin_calc", Sin())
        self.add("sin_verify", Sin())
        self.add("sin_meta_model", MetaModel(params=('x',),
                                             responses=('f_x',)))
        self.sin_meta_model.default_surrogate = NeuralNet(n_hidden_nodes=5)

        #Training the MetaModel
        self.add("DOE_Trainer", DOEdriver())
        self.DOE_Trainer.DOEgenerator = FullFactorial()
        # Seems to need a lot of training data for decent prediction of sin(x),
        # at least with default 'cg' method.
        self.DOE_Trainer.DOEgenerator.num_levels = 2500
        self.DOE_Trainer.add_parameter("sin_calc.x", low=0, high=20)
        self.DOE_Trainer.add_response("sin_calc.f_x")

        self.connect('DOE_Trainer.case_inputs.sin_calc.x',
                     'sin_meta_model.params.x')
        self.connect('DOE_Trainer.case_outputs.sin_calc.f_x',
                     'sin_meta_model.responses.f_x')

        #MetaModel Validation
        self.add("DOE_Validate", DOEdriver())
        self.DOE_Validate.DOEgenerator = Uniform()
        self.DOE_Validate.DOEgenerator.num_samples = 100
        self.DOE_Validate.add_parameter(("sin_meta_model.x", "sin_verify.x"),
                                        low=0, high=20)
        self.DOE_Validate.add_response("sin_verify.f_x")
        self.DOE_Validate.add_response("sin_meta_model.f_x")

        #Iteration Hierarchy
        self.driver.workflow.add(['DOE_Trainer', 'DOE_Validate'])
        self.DOE_Trainer.workflow.add('sin_calc')
        self.DOE_Validate.workflow.add(('sin_verify', 'sin_meta_model'))
Ejemplo n.º 17
0
 def test_doegen_remove(self):
     top = set_as_top(Assembly())
     top.add("driver", DOEdriver())
     top.driver.remove("DOEgenerator")
     top.driver.add("DOEgenerator", FullFactorial())
Ejemplo n.º 18
0
 def test_scaling(self):
     self.model.driver.DOEgenerator = ff = FullFactorial(num_levels=3)
     ff.num_parameters = 4
     for case in self.model.driver._get_cases():
         print case