def fit_with_bfgs_logspace(self):
        """
        Fit the model with BFGS
        """
        # If W_max is specified, set this as a bound
        if self.W_max is not None:
            bnds = [(None, None)] + [(None, np.log(self.W_max))] * (self.K * self.B)
        else:
            bnds = None

        def objective(x, k):
            self.weights[k,:] = np.exp(x)
            self.weights[k,:] = np.nan_to_num(self.weights[k,:])
            return np.nan_to_num(-self.log_posterior(ks=np.array([k])))

        def gradient(x, k):
            self.weights[k,:] = np.exp(x)
            self.weights[k,:] = np.nan_to_num(self.weights[k,:])
            dll_dW =  -self.compute_gradient(k)
            d_W_d_log_W = self._d_W_d_logW(k)
            return np.nan_to_num(dll_dW.dot(d_W_d_log_W))

        itr = [0]
        def callback(x):
            if itr[0] % 10 == 0:
                print "Iteration: %03d\t LP: %.1f" % (itr[0], self.log_posterior())
            itr[0] = itr[0] - 1

        for k in xrange(self.K):
            print "Optimizing process ", k
            itr[0] = 0
            x0 = np.log(self.weights[k,:])
            res = minimize(objective,           # Objective function
                           x0,                  # Initial value
                           jac=gradient,        # Gradient of the objective
                           args=(k,),           # Arguments to the objective and gradient fns
                           bounds=bnds,         # Bounds on x
                           callback=callback)
            self.weights[k,:] = np.exp(res.x)
dataset/ETHPy150Open slinderman/pyhawkes/pyhawkes/models.py/DiscreteTimeStandardHawkesModel.fit_with_bfgs_logspace/operator `+` -> `-`