将遗传优化器转换为驱动程序

时间:2015-08-11 12:06:06

标签: openmdao

我已经拥有了我想要优化的功能的组件。但是,OpenMDAO Alpha 1.0不包含(据我所知)遗传优化器的包装器。我已经写了自己的,现在想把它变成一个驱动程序。我在这里有点失落,我可以要求任何指导吗?

谢谢!

1 个答案:

答案 0 :(得分:3)

您认为OpenMDAO还没有遗传优化器。您可以使用pyopt库中的NSGAII,但由于您有一个想要使用的NSGAII,编写自己的驱动程序应该相当简单。最简单的示例是我们的scipy wrapper优化器。您的包装器必须看起来像这样:

from openmdao.core.driver import Driver

class GeneticOptimizer(Driver):

    def __init__(self):
        super(GeneticOptimizer, self).__init__()

        #some stuff to setup your genetic optimizer here

    def run(self, problem):
        """function called to kick off the optimization

        Args
        ----
        problem : `Problem`
            Our parent `Problem`.

        """

        #NOTE: you'll use these functions to build your optimizer
        #to execute the model
        problem.root.solve_nonlinear()

        #function to set values to the design variables
        self.set_param(var_name, value)