def execute(self):

        self.pyOpt_solution = None

        self.run_iteration()

        opt_prob = Optimization(self.title, self.objfunc, var_set={},
                                obj_set={}, con_set={})

        # Add all parameters
        self.param_type = {}
        self.nparam = self.total_parameters()
        for name, param in self.get_parameters().iteritems():

            # We need to identify Enums, Lists, Dicts
            metadata = param.get_metadata()[1]
            values = param.evaluate()

            # Assuming uniform enumerated, discrete, or continuous for now.
            val = values[0]
            choices = []
            if 'values' in metadata and \
               isinstance(metadata['values'], (list, tuple, array, set)):
                vartype = 'd'
                choices = metadata['values']
            elif isinstance(val, bool):
                vartype = 'd'
                choices = [True, False]
            elif isinstance(val, (int, int32, int64)):
                vartype = 'i'
            elif isinstance(val, (float, float32, float64)):
                vartype = 'c'
            else:
                msg = 'Only continuous, discrete, or enumerated variables' \
                      ' are supported. %s is %s.' % (name, type(val))
                self.raise_exception(msg, ValueError)
            self.param_type[name] = vartype

            names = param.names
            lower_bounds = param.get_low()
            upper_bounds = param.get_high()
            for i in range(param.size):
                opt_prob.addVar(names[i], vartype,
                                lower=lower_bounds[i], upper=upper_bounds[i],
                                value=values[i], choices=choices)
        # Add all objectives
        for name in self.get_objectives():
            opt_prob.addObj(name)

        # Add all equality constraints
        for name, con in self.get_eq_constraints().items():
            if con.size > 1:
                for i in range(con.size):
                    opt_prob.addCon('%s [%s]' % (name, i), type='e')
            else:
                opt_prob.addCon(name, type='e')

        # Add all inequality constraints
        for name, con in self.get_ineq_constraints().items():
            if con.size > 1:
                for i in range(con.size):
                    opt_prob.addCon('%s [%s]' % (name, i), type='i')
            else:
                opt_prob.addCon(name, type='i')

        self.inputs = self.list_param_group_targets()
        self.objs = self.list_objective_targets()
        self.cons = self.list_constraint_targets()

        # Instantiate the requested optimizer
        optimizer = self.optimizer
        try:
            exec('from pyOpt import %s' % optimizer)
        except ImportError:
            msg = "Optimizer %s is not available in this installation." % \
                   optimizer
            self.raise_exception(msg, ImportError)

        optname = vars()[optimizer]
        opt = optname()

        # Set optimization options
        for option, value in self.options.iteritems():
            opt.setOption(option, value)

        # Execute the optimization problem
        if self.pyopt_diff:
            # Use pyOpt's internal finite difference
            opt(opt_prob, sens_type='FD', sens_step=self.gradient_options.fd_step,
                store_hst=self.store_hst, hot_start=self.hot_start)
        else:
            # Use OpenMDAO's differentiator for the gradient
            opt(opt_prob, sens_type=self.gradfunc, store_hst=self.store_hst,
                hot_start=self.hot_start)

        # Print results
        if self.print_results:
            print opt_prob.solution(0)

        # Pull optimal parameters back into framework and re-run, so that
        # framework is left in the right final state
        dvals = []
        for i in range(0, len(opt_prob.solution(0)._variables)):
            dvals.append(opt_prob.solution(0)._variables[i].value)

        # Integer parameters come back as floats, so we need to round them
        # and turn them into python integers before setting.
        if 'i' in self.param_type.values():
            for j, param in enumerate(self.get_parameters().keys()):
                if self.param_type[param] == 'i':
                    dvals[j] = int(round(dvals[j]))

        self.set_parameters(dvals)
        self.run_iteration()

        # Save the most recent solution.
        self.pyOpt_solution = opt_prob.solution(0)
:type root: TreeNode
dataset/ETHPy150Open OpenMDAO-Plugins/pyopt_driver/src/pyopt_driver/pyopt_driver.py/pyOptDriver.execute--crossover with--dataset/ETHPy150Open algorhythms/LeetCode/173 Binary Search Tree Iterator.py/BSTIterator.__init__