Sebastian.Sanchez
Sebastian.Sanchez

Reputation: 85

Convert a genetic optimiser into a Driver

I already have my component with the function I want to optimise. However, OpenMDAO Alpha 1.0 does not contain (to my knowledge) a wrapper for a genetic optimiser. I have written my own, and would now like to make it a Driver. I am a bit lost here, can I ask for any guidance?

Thank you!

Upvotes: 1

Views: 155

Answers (1)

Justin Gray
Justin Gray

Reputation: 5710

You're correct that OpenMDAO doesn't have a genetic optimizer yet. You could use NSGAII from the pyopt library, but since you have one you want to use, writing your own driver should be fairly straightforward. The easiest example to follow would be our scipy wrapper for its optimizers. Your wrapper would have to look something like this:

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)

Upvotes: 3

Related Questions