コード例 #1
0
    def _func(self, m, me, la, n, f, g, xnew):
        """ Return ndarrays containing the function and constraint 
        evaluations.
        
        Note: m, me, la, n, f, and g are unused inputs."""
        self.set_parameters(xnew)
        super(SLSQPdriver, self).run_iteration()      
        f = self.eval_objective()

        if isnan(f):
            msg = "Numerical overflow in the objective."
            self.raise_exception(msg, RuntimeError)
            
        # Constraints
        if self.ncon > 0 :
            con_list = []
            for v in self.get_constraints().values():
                val = v.evaluate(self.parent)
                if '>' in val[2]:
                    con_list.append(val[0]-val[1])
                else:
                    con_list.append(val[1]-val[0])
                
            g = array(con_list)
            
            
        if self.iprint > 0:
            pyflush(self.iout)
            
        # Write out some relevant information to the recorder
        self.record_case()

        return f, g
コード例 #2
0
    def _func(self, m, me, la, n, f, g, xnew):
        """ Return ndarrays containing the function and constraint 
        evaluations.
        
        Note: m, me, la, n, f, and g are unused inputs."""
        self.set_parameters(xnew)
        super(SLSQPdriver, self).run_iteration()      
        f = self.eval_objective()

        if isnan(f):
            msg = "Numerical overflow in the objective."
            self.raise_exception(msg, RuntimeError)
            
        # Constraints. Note that SLSQP defines positive as satisfied.
        if self.ncon > 0 :
            con_list = [-v.evaluate(self.parent) for \
                        v in self.get_constraints().values()]
            g = array(con_list)
            
        if self.iprint > 0:
            pyflush(self.iout)
            
        # Write out some relevant information to the recorder
        self.record_case()
        
        return f, g
コード例 #3
0
    def _func(self, m, me, la, n, f, g, xnew):
        """ Return ndarrays containing the function and constraint 
        evaluations.
        
        Note: m, me, la, n, f, and g are unused inputs."""
        self.set_parameters(xnew)
        super(SLSQPdriver, self).run_iteration()      
        f = self.eval_objective()

        if isnan(f):
            msg = "Numerical overflow in the objective"
            self.raise_exception(msg, RuntimeError)
            
        # Constraints
        if self.ncon > 0 :
            con_list = []
            for v in self.get_constraints().values():
                val = v.evaluate(self.parent)
                if '>' in val[2]:
                    con_list.append(val[0]-val[1])
                else:
                    con_list.append(val[1]-val[0])
                
            g = array(con_list)
            
            
        if self.iprint > 0:
            pyflush(self.iout)
            
        # Write out some relevant information to the recorder
        if self.recorders:
            
            case_input = []
            for var, val in zip(self.get_parameters().keys(), xnew):
                case_name = var[0] if isinstance(var, tuple) else var
                case_input.append([case_name, val])
            if self.printvars:
                case_output = [(name,
                                ExprEvaluator(name, scope=self.parent).evaluate())
                                       for name in self.printvars]
            else:
                case_output = []
            case_output.append(["objective", f])
        
            for i, val in enumerate(g):
                case_output.append(["Constraint%d" % i, val])
            
            case = Case(case_input, case_output, parent_uuid=self._case_id)
            
            for recorder in self.recorders:
                recorder.record(case)

            
        return f, g
コード例 #4
0
    def _func(self, m, me, la, n, f, g, xnew):
        """ Return ndarrays containing the function and constraint
        evaluations.

        Note: m, me, la, n, f, and g are unused inputs."""
        self.set_parameters(xnew)
        super(SLSQPdriver, self).run_iteration()
        f = self.eval_objective()

        if isnan(f):
            msg = "Numerical overflow in the objective."
            self.raise_exception(msg, RuntimeError)

        # Constraints. Note that SLSQP defines positive as satisfied.
        if self.ncon > 0:
            g = -1. * array(self.eval_constraints(self.parent))

        if self.iprint > 0:
            pyflush(self.iout)

        return f, g
コード例 #5
0
    def _func(self, m, me, la, n, f, g, xnew):
        """ Return ndarrays containing the function and constraint
        evaluations.

        Note: m, me, la, n, f, and g are unused inputs."""
        self.set_parameters(xnew)
        super(SLSQPdriver, self).run_iteration()
        f = self.eval_objective()

        if isnan(f):
            msg = "Numerical overflow in the objective."
            self.raise_exception(msg, RuntimeError)

        # Constraints. Note that SLSQP defines positive as satisfied.
        if self.ncon > 0:
            g = -1. * array(self.eval_constraints(self.parent))

        if self.iprint > 0:
            pyflush(self.iout)

        return f, g