コード例 #1
0
    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')
コード例 #2
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')
コード例 #3
0
ファイル: hyperAssembly.py プロジェクト: thearn/Hyperloop
    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'])  #
コード例 #4
0
    def configure(self):
        self.add('paraboloid', Paraboloid())

        self.add('driver', DOEdriver())
        self.driver.log_level = logging.INFO

        # Configure the generator.
        self.driver.DOEgenerator = MonteCarlo()
        self.driver.DOEgenerator.num_samples = 5000
        self.driver.DOEgenerator.dist_types = {
            'Default':random.uniform, 'y':random.standard_normal}
        self.driver.DOEgenerator.dist_args = {'Default':[0, 1], 'y':[]}
        self.driver.DOEgenerator.parameters = ['x', 'y']

        # Configure driver parameters.
        self.driver.add_parameter('paraboloid.x', low=0, high=1)
        self.driver.add_parameter('paraboloid.y', low=0, high=1)

        #tell the DOEdriver to also record f_xy.
        self.driver.add_response('paraboloid.f_xy')

        #Simple recorder which stores the cases in memory.
        self.recorders = [ListCaseRecorder(),]

        self.driver.workflow.add('paraboloid')
コード例 #5
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 = MonteCarlo()
        self.driver.DOEgenerator.num_samples = 5000
        self.driver.DOEgenerator.dist_types = {
            'Default': random.uniform,
            'y': random.standard_normal
        }
        self.driver.DOEgenerator.dist_args = {'Default': [0, 1], 'y': []}
        self.driver.DOEgenerator.parameters = ['x', 'y']

        #DOEdriver will automatically record the values of any parameters for each case
        self.driver.add_parameter('paraboloid.x', low=0, high=1)
        self.driver.add_parameter('paraboloid.y', low=0, high=1)
        #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')
コード例 #6
0
ファイル: runDOE.py プロジェクト: cmheath/FFD
    def __init__(self):
        super(Analysis, self).__init__()
        
        # --------------------------------------------------------------------------- #
        # --- Instantiate LHC DOE Driver
        # --------------------------------------------------------------------------- #  
        self.add('doe_driver', DOEdriver())  
        self.doe_driver.DOEgenerator = Uniform(num_samples = 5)
        self.doe_driver.workflow = SequentialWorkflow()
       
        # --------------------------------------------------------------------------- #
        # --- Instantiate Geometry Component
        # --------------------------------------------------------------------------- #  
        self.add('geometry', GeometryComp()) 

        # 1--- Top Level Workflow
        self.driver.workflow.add(['doe_driver']) 
        self.doe_driver.workflow.add(['geometry'])
    
        # --------------------------------------------------------------------------- #
        # --- Add parameters to DOE driver 
        # --------------------------------------------------------------------------- #         
        self.doe_driver.add_parameter('geometry.dC1P_X')
        self.doe_driver.add_parameter('geometry.dC2P_X')
        self.doe_driver.add_parameter('geometry.dC3P_X')
        self.doe_driver.add_parameter('geometry.dC4P_X')

        self.doe_driver.add_parameter('geometry.dC1P_R')
        self.doe_driver.add_parameter('geometry.dC2P_R')
        self.doe_driver.add_parameter('geometry.dC3P_R')
        self.doe_driver.add_parameter('geometry.dC4P_R')

        self.doe_driver.add_parameter('geometry.dC1S_X')
        self.doe_driver.add_parameter('geometry.dC2S_X')
        self.doe_driver.add_parameter('geometry.dC3S_X')
        self.doe_driver.add_parameter('geometry.dC4S_X')

        self.doe_driver.add_parameter('geometry.dC1S_R')
        self.doe_driver.add_parameter('geometry.dC2S_R')
        self.doe_driver.add_parameter('geometry.dC3S_R')
        self.doe_driver.add_parameter('geometry.dC4S_R')
       
        self.doe_driver.add_parameter('geometry.dC1S_T')
        self.doe_driver.add_parameter('geometry.dC2S_T')
        self.doe_driver.add_parameter('geometry.dC3S_T')

        self.doe_driver.add_parameter('geometry.dC1C_X')
        self.doe_driver.add_parameter('geometry.dC2C_X')
        self.doe_driver.add_parameter('geometry.dC3C_X')
        self.doe_driver.add_parameter('geometry.dC4C_X')

        self.doe_driver.add_parameter('geometry.dC1C_R')
        self.doe_driver.add_parameter('geometry.dC2C_R')
        self.doe_driver.add_parameter('geometry.dC3C_R')
        self.doe_driver.add_parameter('geometry.dC4C_R')
       
        self.doe_driver.add_parameter('geometry.dC1C_T')
        self.doe_driver.add_parameter('geometry.dC2C_T')
        self.doe_driver.add_parameter('geometry.dC3C_T')        
コード例 #7
0
ファイル: doe2.py プロジェクト: sebasanper/doe
 def configure(self):
     self.add('paraboloid', Paraboloid())
     doe = self.add('driver', DOEdriver())
     doe.DOEgenerator = Uniform(num_samples=1000)
     doe.add_parameter('paraboloid.x', low=-50, high=50)
     doe.add_parameter('paraboloid.y', low=-50, high=50)
     doe.case_outputs = ['paraboloid.f_xy']
     doe.workflow.add('paraboloid')
コード例 #8
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'])
コード例 #9
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'])
コード例 #10
0
ファイル: multi_outs.py プロジェクト: RubenvdBerg/SatToolAG
    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')
コード例 #11
0
    def configure(self):
        self.add('paraboloid', Paraboloid())

        self.add('driver', DOEdriver())
        self.driver.DOEgenerator = Uniform(1000)

        self.driver.add_parameter('paraboloid.x', low=-50, high=50)
        self.driver.add_parameter('paraboloid.y', low=-50, high=50)

        self.driver.add_response('paraboloid.f_xy')

        self.recorders = [JSONCaseRecorder(out='doe.json')]
コード例 #12
0
    def __init__(self):
        super(Analysis, self).__init__()

        # --------------------------------------------------------------------------- #
        # --- Instantiate LHC DOE Driver
        # --------------------------------------------------------------------------- #
        self.add('doe_driver', DOEdriver())
        self.doe_driver.DOEgenerator = OptLatinHypercube(num_samples=10)
        self.doe_driver.workflow = SequentialWorkflow()

        # --------------------------------------------------------------------------- #
        # --- Instantiate LHC Adapter Component
        # --- Modifies LHC to convert continuous design variable to discrete
        # --------------------------------------------------------------------------- #
        self.add('adapter', AdapterComp())

        # --------------------------------------------------------------------------- #
        # --- Instantiate Geometry Component
        # --------------------------------------------------------------------------- #
        self.add('geometry', GeometryComp())

        # 1--- Top Level Workflow
        self.driver.workflow.add(['doe_driver'])
        self.doe_driver.workflow.add(['adapter', 'geometry'])

        # --------------------------------------------------------------------------- #
        # --- Add parameters to DOE driver
        # --------------------------------------------------------------------------- #
        self.doe_driver.add_parameter('adapter.vane_num')
        self.doe_driver.add_parameter('adapter.injector_loc')
        self.doe_driver.add_parameter('adapter.injector_dia')
        self.doe_driver.add_parameter('geometry.vane_pitch')
        self.doe_driver.add_parameter('geometry.venturi_angle')

        # --------------------------------------------------------------------------- #
        # Specify DBcaseRecorder for DOE
        # --------------------------------------------------------------------------- #
        self.doe_driver.case_outputs = [
            'adapter.vane_num_out', 'adapter.injector_loc_out',
            'adapter.injector_dia_out', 'geometry.vane_num',
            'geometry.injector_loc', 'geometry.injector_dia'
        ]
        self.doe_driver.recorder = DBCaseRecorder(DOE_OUT_DB)

        #self.add('DOE_restart', DBCaseIterator(DOE_OUT_DB))

        # --------------------------------------------------------------------------- #
        # --- Specify Non-NPSS Data Connections
        # --------------------------------------------------------------------------- #
        self.connect('adapter.vane_num_out', 'geometry.vane_num')
        self.connect('adapter.injector_loc_out', 'geometry.injector_loc')
        self.connect('adapter.injector_dia_out', 'geometry.injector_dia')
コード例 #13
0
ファイル: test_neural_net.py プロジェクト: afcarl/neural_net
    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'))
コード例 #14
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)
コード例 #15
0
ファイル: doe.py プロジェクト: QPanProjects/Surrogate-Model
    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
        self.driver.DOEgenerator = Uniform(1000)

        # 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.add_response('paraboloid.f_xy')

        self.recorders = [
            JSONCaseRecorder('doe.json'),
            BSONCaseRecorder('doe.bson')
        ]
コード例 #16
0
ファイル: doe.py プロジェクト: RubenvdBerg/SatToolAG
 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')
コード例 #17
0
    def configure(self):
        """Creates a new Assembly containing a PlugNozzleGeometry and DOE"""

        self.replace("driver", DOEdriver())

        self.driver.add("DOEgenerator", LatinHypercube(num_samples=5))

        self.add("plug_noz", PlugNozzleGeometry())

        self.driver.add_parameter('plug_noz.cowl.thickness[7]',
                                  low=0.0,
                                  high=0.5)
        self.driver.add_parameter('plug_noz.cowl.thickness[8]',
                                  low=0.0,
                                  high=0.5)
        self.driver.add_parameter('plug_noz.cowl.R[7]', low=-0.1, high=0.2)
        self.driver.add_parameter('plug_noz.cowl.R[8]', low=-0.1, high=0.2)
        self.driver.add_parameter('plug_noz.plug.R[7]', low=-0.1, high=0.5)
        self.driver.add_parameter('plug_noz.plug.R[8]', low=-0.1, high=0.5)
コード例 #18
0
    def __init__(self, *args, **kwargs):
        super(Analysis, self).__init__(self, *args, **kwargs)

        self._tdir = mkdtemp()

        #Components
        self.add("A", MetaModel())
        self.A.surrogate = {'default': KrigingSurrogate()}
        self.A.model = ConceptA()
        self.A.recorder = DBCaseRecorder(':memory:')

        self.add('DOE_maker', DOE_Maker())
        self.DOE_maker.cases = [10] * 3
        #self.DOE_maker.force_execute = True

        #Drivers
        self.add("trainA", DOEdriver())
        self.trainA.sequential = True
        self.trainA.add_parameter("A.x")
        self.trainA.add_parameter("A.y")
        self.trainA.add_parameter("A.z")
        self.trainA.add_event("A.train_next")
        self.trainA.case_outputs = ['A.f1', 'A.f2']
        self.trainA.recorder = DBCaseRecorder(os.path.join(self._tdir, 'A.db'))

        self.add('driver', Iterator())
        self.driver.add_stop_condition('len(DOE_maker.cases)==0')
        self.driver.add_event('A.reset_training_data')

        self.add('res', Res())
        self.res.force_execute = True

        #Iteration Hierarchy
        self.driver.workflow.add(['DOE_maker', 'trainA', 'res'])
        #self.driver.workflow.add(['DOE_maker','trainA'])
        self.trainA.workflow.add('A')

        #Data Connections
        self.connect('DOE_maker.DOEgen', 'trainA.DOEgenerator')
コード例 #19
0
    def configure(self):    
        self._tdir = mkdtemp()        
        
        self.comp_name = None
        #check to make sure no more than one component is being referenced
        compnames = set()
        for param in self.parent.get_parameters().values():
            compnames.update(param.get_referenced_compnames())

        if len(compnames) > 1:
            self.parent.raise_exception('The EGO architecture can only be used on one'
                                        'component at a time, but parameters from %s '
                                        'were added to the problem formulation.' %compnames, 
                                        ValueError)
        self.comp_name = compnames.pop()        
        #change name of component to add '_model' to it. 
        #     lets me name the metamodel as the old name
        self.comp= getattr(self.parent,self.comp_name)
        self.comp.name = "%s_model"%self.comp_name
        
        #add in the metamodel
        meta_model = self.parent.add(self.comp_name,MetaModel()) #metamodel now replaces old component with same name
        meta_model.default_surrogate = KrigingSurrogate()
        meta_model.model = self.comp
        
        meta_model_recorder = DBCaseRecorder(os.path.join(self._tdir,'trainer.db'))
        meta_model.recorder = meta_model_recorder
        
        EI = self.parent.add("EI",ExpectedImprovement())
        self.objective = self.parent.get_objectives().keys()[0]
        EI.criteria = self.objective
        
        pfilter = self.parent.add("filter",ParetoFilter())
        pfilter.criteria = [self.objective]
        pfilter.case_sets = [meta_model_recorder.get_iterator(),]
        
        #Driver Configuration
        DOE_trainer = self.parent.add("DOE_trainer",DOEdriver())
        DOE_trainer.sequential = True
        DOE_trainer.DOEgenerator = OptLatinHypercube(num_samples=self.initial_DOE_size)
        
        for name,param in self.parent.get_parameters().iteritems(): 
            DOE_trainer.add_parameter(param)

        DOE_trainer.add_event("%s.train_next"%self.comp_name)
        
        DOE_trainer.case_outputs = [self.objective]
        DOE_trainer.recorders = [DBCaseRecorder(':memory:')]
        
        EI_opt = self.parent.add("EI_opt",Genetic())
        EI_opt.opt_type = "maximize"
        EI_opt.population_size = 100
        EI_opt.generations = 10
        #EI_opt.selection_method = "tournament"
        
        for name,param in self.parent.get_parameters().iteritems(): 
            EI_opt.add_parameter(param)
        EI_opt.add_objective("EI.%s"%self.EI_PI)
        
        retrain = self.parent.add("retrain",Driver())
        retrain.recorders = self.data_recorders
        
        retrain.add_event("%s.train_next"%self.comp_name)
        
        iter = self.parent.add("iter",IterateUntil())
        iter.max_iterations = self.sample_iterations
        iter.add_stop_condition('EI.PI <= %s'%self.min_ei_pi)
        
        #Data Connections
        self.parent.connect("filter.pareto_set","EI.best_case")
        self.parent.connect(self.objective,"EI.predicted_value")        
        
        #Iteration Heirarchy
        self.parent.driver.workflow.add(['DOE_trainer', 'iter'])
        #DOE_trainer.workflow.add(self.comp_name)
        
        iter.workflow = SequentialWorkflow()
        iter.workflow.add(['filter', 'EI_opt', 'retrain'])
        
        #EI_opt.workflow.add([self.comp_name,'EI'])
        retrain.workflow.add(self.comp_name)
コード例 #20
0
    def configure(self):

        self._tdir = mkdtemp()

        #Components
        self.add("branin_meta_model", MetaModel())
        self.branin_meta_model.default_surrogate = KrigingSurrogate()
        self.branin_meta_model.model = BraninComponent()
        self.branin_meta_model.recorder = DBCaseRecorder(':memory:')
        self.branin_meta_model.force_execute = True

        self.add("EI", ExpectedImprovement())
        self.EI.criteria = "branin_meta_model.f_xy"

        self.add("filter", ParetoFilter())
        self.filter.criteria = ['branin_meta_model.f_xy']
        self.filter.case_sets = [
            self.branin_meta_model.recorder.get_iterator(),
        ]
        self.filter.force_execute = True
        #Driver Configuration
        self.add("DOE_trainer", DOEdriver())
        self.DOE_trainer.sequential = True
        self.DOE_trainer.DOEgenerator = OptLatinHypercube(num_samples=15)
        #self.DOE_trainer.DOEgenerator = FullFactorial(num_levels=5)
        self.DOE_trainer.add_parameter("branin_meta_model.x",
                                       low=-5.,
                                       high=10.)
        self.DOE_trainer.add_parameter("branin_meta_model.y", low=0., high=15.)

        self.DOE_trainer.add_event("branin_meta_model.train_next")
        self.DOE_trainer.case_outputs = ["branin_meta_model.f_xy"]
        self.DOE_trainer.recorders = [
            DBCaseRecorder(os.path.join(self._tdir, 'trainer.db'))
        ]

        self.add("EI_opt", Genetic())
        self.EI_opt.opt_type = "maximize"
        self.EI_opt.population_size = 100
        self.EI_opt.generations = 10
        #self.EI_opt.selection_method = "tournament"
        self.EI_opt.add_parameter("branin_meta_model.x", low=-5., high=10.)
        self.EI_opt.add_parameter("branin_meta_model.y", low=0., high=15.)

        self.EI_opt.add_objective("EI.PI")

        self.add("retrain", MyDriver())
        self.retrain.add_event("branin_meta_model.train_next")
        self.retrain.recorders = [
            DBCaseRecorder(os.path.join(self._tdir, 'retrain.db'))
        ]

        self.add("iter", IterateUntil())
        self.iter.max_iterations = 30
        self.iter.add_stop_condition('EI.EI <= .0001')

        #Iteration Heirarchy
        self.driver.workflow.add(['DOE_trainer', 'iter'])

        self.DOE_trainer.workflow.add('branin_meta_model')

        self.iter.workflow = SequentialWorkflow()
        self.iter.workflow.add(['filter', 'EI_opt', 'retrain'])

        self.EI_opt.workflow.add(['branin_meta_model', 'EI'])
        self.retrain.workflow.add('branin_meta_model')

        #Data Connections
        self.connect("filter.pareto_set", "EI.best_case")
        self.connect("branin_meta_model.f_xy", "EI.predicted_value")
コード例 #21
0
    def configure(self):

        self._tdir = mkdtemp()

        #Components
        self.add("spiral_meta_model", MetaModel())
        self.spiral_meta_model.surrogate = {'default': KrigingSurrogate()}
        self.spiral_meta_model.model = SpiralComponent()
        self.spiral_meta_model.recorder = DBCaseRecorder(':memory:')
        self.spiral_meta_model.force_execute = True

        self.add("MOEI", MultiObjExpectedImprovement())
        self.MOEI.criteria = [
            'spiral_meta_model.f1_xy', 'spiral_meta_model.f2_xy'
        ]

        self.add("filter", ParetoFilter())
        self.filter.criteria = [
            'spiral_meta_model.f1_xy', 'spiral_meta_model.f2_xy'
        ]
        self.filter.case_sets = [
            self.spiral_meta_model.recorder.get_iterator()
        ]
        self.filter.force_execute = True

        #Driver Configuration
        self.add("DOE_trainer", DOEdriver())
        self.DOE_trainer.sequential = True
        self.DOE_trainer.DOEgenerator = OptLatinHypercube(num_samples=25)
        self.DOE_trainer.add_parameter("spiral_meta_model.x")
        self.DOE_trainer.add_parameter("spiral_meta_model.y")
        self.DOE_trainer.add_event("spiral_meta_model.train_next")
        self.DOE_trainer.case_outputs = [
            'spiral_meta_model.f1_xy', 'spiral_meta_model.f2_xy'
        ]
        self.DOE_trainer.recorders = [
            DBCaseRecorder(os.path.join(self._tdir, 'trainer.db'))
        ]

        self.add("MOEI_opt", Genetic())
        self.MOEI_opt.opt_type = "maximize"
        self.MOEI_opt.population_size = 100
        self.MOEI_opt.generations = 10
        #self.MOEI_opt.selection_method = "tournament"
        self.MOEI_opt.add_parameter("spiral_meta_model.x")
        self.MOEI_opt.add_parameter("spiral_meta_model.y")
        self.MOEI_opt.add_objective("MOEI.PI")

        self.add("retrain", MyDriver())
        self.retrain.add_event("spiral_meta_model.train_next")
        self.retrain.recorders = [
            DBCaseRecorder(os.path.join(self._tdir, 'retrain.db'))
        ]

        self.add("iter", IterateUntil())
        self.iter.iterations = 30
        self.iter.add_stop_condition('MOEI.PI <= .0001')

        #Iteration Heirarchy
        self.driver.workflow.add(['DOE_trainer', 'iter'])

        self.DOE_trainer.workflow.add('spiral_meta_model')

        self.iter.workflow = SequentialWorkflow()
        self.iter.workflow.add(['filter', 'MOEI_opt', 'retrain'])

        self.MOEI_opt.workflow.add(['spiral_meta_model', 'MOEI'])
        self.retrain.workflow.add('spiral_meta_model')

        #Data Connections
        self.connect("filter.pareto_set", "MOEI.best_cases")
        self.connect("spiral_meta_model.f1_xy", "MOEI.predicted_values[0]")
        self.connect("spiral_meta_model.f2_xy", "MOEI.predicted_values[1]")