def objfunc(self, x, *args, **kwargs):

        fail = 1
        f = []
        g = []

        try:

            # Note: Sometimes pyOpt sends us an x array that is larger than
            # the number of parameters. In the pyOpt examples, they just take
            # the first n entries as the parameters, so we do too.

            # Integer parameters come back as floats, so we need to round them
            # and turn them into python integers before setting.
            param_types = self.param_type
            if 'i' in param_types.values():
                j = 0
                for name, param in self.get_parameters().iteritems():
                    size = param.size
                    if param_types[name] == 'i':
                        self.set_parameter_by_name(name, int(round(x[j:j+size])))
                    else:
                        self.set_parameter_by_name(name, x[j:j+size])
                    j += size
            else:
                self.set_parameters(x[0:self.nparam])

            # Execute the model
            self.run_iteration()

            # Get the objective function evaluations
            f = array(self.eval_objectives())

            # Get the constraint evaluations
            g = array(self.eval_constraints(self.parent)).tolist()

            fail = 0

        except Exception as msg:

            # Exceptions seem to be swallowed by the C code, so this
            # should give the user more info than the dreaded "segfault"
            print "Exception: %s" % str(msg)
            print 70*"="
            import traceback
            traceback.print_exc()
            print 70*"="

        return f, g, fail
Function that evaluates and returns the objective function and
dataset/ETHPy150Open OpenMDAO-Plugins/pyopt_driver/src/pyopt_driver/pyopt_driver.py/pyOptDriver.objfunc