Esempio n. 1
0
    def opt(self, f_fp=None, f=None, fp=None):
        """
        Run Rasmussen's Conjugate Gradient optimizer
        """

        assert f_fp != None, "Rasmussen's minimizer requires f_fp"
        statuses = [
            'Converged', 'Line search failed',
            'Maximum number of f evaluations reached', 'NaNs in optimization'
        ]

        opt_dict = {}
        if self.xtol is not None:
            print(
                "WARNING: minimize doesn't have an xtol arg, so I'm going to ignore it"
            )
        if self.ftol is not None:
            print(
                "WARNING: minimize doesn't have an ftol arg, so I'm going to ignore it"
            )
        if self.gtol is not None:
            print(
                "WARNING: minimize doesn't have an gtol arg, so I'm going to ignore it"
            )

        opt_result = rasm.minimize(self.x_init,
                                   f_fp, (),
                                   messages=self.messages,
                                   maxnumfuneval=self.max_f_eval)
        self.x_opt = opt_result[0]
        self.f_opt = opt_result[1][-1]
        self.funct_eval = opt_result[2]
        self.status = statuses[opt_result[3]]

        self.trace = opt_result[1]
Esempio n. 2
0
    def opt(self, f_fp=None, f=None, fp=None):
        """
        Run Rasmussen's Conjugate Gradient optimizer
        """

        assert f_fp != None, "Rasmussen's minimizer requires f_fp"
        statuses = ['Converged', 'Line search failed', 'Maximum number of f evaluations reached',
                'NaNs in optimization']

        opt_dict = {}
        if self.xtol is not None:
            print "WARNING: minimize doesn't have an xtol arg, so I'm going to ignore it"
        if self.ftol is not None:
            print "WARNING: minimize doesn't have an ftol arg, so I'm going to ignore it"
        if self.gtol is not None:
            print "WARNING: minimize doesn't have an gtol arg, so I'm going to ignore it"

        opt_result = rasm.minimize(self.x_init, f_fp, (), messages=self.messages,
                                   maxnumfuneval=self.max_f_eval)
        self.x_opt = opt_result[0]
        self.f_opt = opt_result[1][-1]
        self.funct_eval = opt_result[2]
        self.status = statuses[opt_result[3]]

        self.trace = opt_result[1]