def setOptimizer(self, method, num_restarts=None, min_threshold=None, meanRange=None, covRange=None, likRange=None): '''Set optimizer. See base class.''' conf = None if (num_restarts != None) or (min_threshold != None): conf = pyGPs.Optimization.conf.random_init_conf( self.meanfunc, self.covfunc, self.likfunc) conf.num_restarts = num_restarts conf.min_threshold = min_threshold if meanRange != None: conf.meanRange = meanRange if covRange != None: conf.covRange = covRange if likRange != None: conf.likRange = likRange if method == "Minimize": self.optimizer = opt.Minimize(self, conf) elif method == "SCG": self.optimizer = opt.SCG(self, conf) elif method == "CG": self.optimizer = opt.CG(self, conf) elif method == "BFGS": self.optimizer = opt.BFGS(self, conf) elif method == "LBFGSB": self.optimizer = opt.LBFGSB(self, conf) elif method == "COBYLA": self.optimizer = opt.COBYLA(self, conf)
def setOptimizer(self, method, num_restarts=None, min_threshold=None, meanRange=None, covRange=None, likRange=None): ''' Overriding. Usage see base class pyGPs.gp.GP.setOptimizer ''' conf = None if (num_restarts != None) or (min_threshold != None): conf = pyGPs.Optimization.conf.random_init_conf( self.meanfunc, self.covfunc, self.likfunc) conf.num_restarts = num_restarts conf.min_threshold = min_threshold if not meanRange is None: conf.meanRange = meanRange if not covRange is None: conf.covRange = covRange if not likRange is None: conf.likRange = likRange if method == "Minimize": self.optimizer = opt.Minimize(self, conf) elif method == "SCG": self.optimizer = opt.SCG(self, conf) elif method == "CG": self.optimizer = opt.CG(self, conf) elif method == "BFGS": self.optimizer = opt.BFGS(self, conf) elif method == "LBFGSB": self.optimizer = opt.LBFGSB(self, conf) elif method == "COBYLA": self.optimizer = opt.COBYLA(self, conf) elif method == "RTMinimize": self.optimizer = opt.RTMinimize(self, conf) else: raise Error( 'Optimization method is not set correctly in setOptimizer')