def configure(self):

        driver = self.add('driver', FixedPointIterator())
        adapt = self.add('adapt', AdaptiveSampleDriver())
        ei_opt = self.add('ei_opt', Genetic())

        branin = self.add('branin', BraninComponent())

        kwargs = {'params': ("x", "y"), 'responses': ('f_xy', )}

        meta = self.add('meta', MetaModel(**kwargs))
        meta.default_surrogate = KrigingSurrogate()
        pareto = self.add('pareto', ParetoFilter(**kwargs))

        ei = self.add('ei', ExpectedImprovement())

        #initial training DOE
        adapt.DOEgenerator = OptLatinHypercube(num_samples=15)
        #adapt.DOEgenerator = Uniform(100)
        adapt.add_parameter('branin.x', low=-5, high=10)
        adapt.add_parameter('branin.y', low=0, high=15)
        adapt.add_response('branin.f_xy')

        #pass training data from sampler to metamodel and pareto filter
        self.connect('adapt.all_case_inputs.branin.x',
                     ['meta.params.x', 'pareto.params.x'])
        self.connect('adapt.all_case_inputs.branin.y',
                     ['meta.params.y', 'pareto.params.y'])
        self.connect('adapt.all_case_outputs.branin.f_xy',
                     ['meta.responses.f_xy', 'pareto.responses.f_xy'])

        #connect meta and pareto to ei
        self.connect('meta.f_xy',
                     'ei.current')  #this passes a normal distribution variable
        self.connect(
            'pareto.pareto_outputs[0, 0]', 'ei.target'
        )  #for single objective, frontier is just a scalar value that is the minimum of the set

        #EI optimization to find next point
        ei_opt.opt_type = "maximize"
        ei_opt.population_size = 100
        ei_opt.generations = 10
        ei_opt.add_parameter('meta.x', low=-5, high=10)
        ei_opt.add_parameter('meta.y', low=0, high=15)
        ei_opt.add_objective('ei.PI')  #could use ei.EI too

        #Iterative sampling process
        driver.add_parameter('adapt.adaptive_inputs.branin.x[0]')
        driver.add_parameter('adapt.adaptive_inputs.branin.y[0]')
        driver.add_constraint('adapt.adaptive_inputs.branin.x[0] = meta.x')
        driver.add_constraint('adapt.adaptive_inputs.branin.y[0] = meta.y')
        driver.max_iterations = 30

        #Iteration Heirarchy
        driver.workflow.add(['adapt', 'pareto', 'ei_opt'])
        adapt.workflow.add(['branin'])
        ei_opt.workflow.add(['meta', 'ei'])

        #FPI now support stop conditions
        driver.add_stop_condition('ei.EI <= .0001')
    def configure(self):
        driver = self.add('driver', FixedPointIterator())
        adapt = self.add('adapt', AdaptiveSampleDriver())
        MOEI_opt = self.add('MOEI_opt', Genetic())

        self.add('spiral', SpiralComponent())

        kwargs = {'params': ("x", "y"), 'responses': ('f1_xy', 'f2_xy')}

        meta = self.add('meta', MetaModel(**kwargs))
        meta.default_surrogate = KrigingSurrogate()
        self.add('pareto', ParetoFilter(**kwargs))

        self.add('MOEI', MultiObjExpectedImprovement())

        # initial training DOE
        adapt.DOEgenerator = OptLatinHypercube(num_samples=25)
        adapt.add_parameter('spiral.x')
        adapt.add_parameter('spiral.y')
        adapt.add_response('spiral.f1_xy')
        adapt.add_response('spiral.f2_xy')

        # pass training data from sampler to metamodel and pareto filter
        self.connect('adapt.all_case_inputs.spiral.x',
                     ['meta.params.x', 'pareto.params.x'])
        self.connect('adapt.all_case_inputs.spiral.y',
                     ['meta.params.y', 'pareto.params.y'])
        self.connect('adapt.all_case_outputs.spiral.f1_xy',
                     ['meta.responses.f1_xy', 'pareto.responses.f1_xy'])
        self.connect('adapt.all_case_outputs.spiral.f2_xy',
                     ['meta.responses.f2_xy', 'pareto.responses.f2_xy'])

        # connect meta and pareto to ei
        self.connect('[meta.f1_xy, meta.f2_xy]', 'MOEI.current')
        self.connect('pareto.pareto_outputs', 'MOEI.target')

        # MOEI optimization to find next point
        MOEI_opt.opt_type = "maximize"
        MOEI_opt.population_size = 100
        MOEI_opt.generations = 10
        # MOEI_opt.selection_method = "tournament"
        MOEI_opt.add_parameter("meta.x", low=0.75, high=5. * pi)
        MOEI_opt.add_parameter("meta.y", low=0.75, high=5. * pi)
        MOEI_opt.add_objective("MOEI.PI")

        # Iterative sampling process
        driver.add_parameter('adapt.adaptive_inputs.spiral.x[0]')
        driver.add_parameter('adapt.adaptive_inputs.spiral.y[0]')
        driver.add_constraint('adapt.adaptive_inputs.spiral.x[0] = meta.x')
        driver.add_constraint('adapt.adaptive_inputs.spiral.y[0] = meta.y')
        driver.max_iterations = 30

        # Iteration Heirarchy
        driver.workflow.add(['adapt', 'pareto', 'MOEI_opt'])
        adapt.workflow.add(['spiral'])
        MOEI_opt.workflow.add(['meta', 'MOEI'])

        # FPI now support stop conditions
        driver.add_stop_condition('MOEI.PI <= .0001')
Beispiel #3
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