def run(self):
    'Runs BP algorithm.'
    tic = time.time()
    max_diff = np.inf
    while ((self._iters < self.maxiter) and (max_diff > self.tol) and ((time.time() - tic) < self.maxtime)):
        if (self.updates == 'SEQMAX'):
            if (self._iters == 0):
                for i in range(self.nrVars):
                    for ii in self.nbV[i]:
                        self._calc_new_message(i, ii.iter)
            for _ in range(len(self._update_seq)):
                (i, _I) = self.find_max_residual()
                self._update_message(i, _I)
                for J in self.nbV[i]:
                    if (J.iter != _I):
                        for j in self.nbF[J.node]:
                            _J = j.dual
                            if (j != i):
                                self._calc_new_message(j.node, _J)
        elif (self.updates == 'PARALL'):
            for i in range(self.nrVars):
                for ii in self.nbV[i]:
                    self._calc_new_message(i, ii.iter)
            for i in range(self.nrVars):
                for ii in self.nbV[i]:
                    self._update_message(i, ii.iter)
        else:
            if (self.updates == 'SEQRND'):
                random.shuffle(self._update_seq)
            for e in self._update_seq:
                self._calc_new_message(e[0], e[1])
                self._update_message(e[0], e[1])
        max_diff = (- np.inf)
        for i in range(self.nrVars):
            b = self._belief_v(i).clone()
            max_diff = max(max_diff, dist_linf(b.p, self._oldBeliefsV[i].p))
            self._oldBeliefsV[i] = b
        for ii in range(self.nrFactors):
            b = self._belief_f(ii).clone()
            max_diff = max(max_diff, dist_linf(b.p, self._old_beliefs_f[ii].p))
            self._old_beliefs_f[ii] = b
        self._iters += 1
    if (max_diff > self._maxdiff):
        self._maxdiff = max_diff
    return max_diff
Runs BP algorithm.
def run(self):
    
    tic = time.time()
    max_diff = np.inf
    while ((self._iters < self.maxiter) and (max_diff > self.tol) and ((time.time() - tic) < self.maxtime)):
        if (self.updates == 'SEQMAX'):
            if (self._iters == 0):
                for i in range(self.nrVars):
                    for ii in self.nbV[i]:
                        self._calc_new_message(i, ii.iter)
            for _ in range(len(self._update_seq)):
                (i, _I) = self.find_max_residual()
                self._update_message(i, _I)
                for J in self.nbV[i]:
                    if (J.iter != _I):
                        for j in self.nbF[J.node]:
                            _J = j.dual
                            if (j != i):
                                self._calc_new_message(j.node, _J)
        elif (self.updates == 'PARALL'):
            for i in range(self.nrVars):
                for ii in self.nbV[i]:
                    self._calc_new_message(i, ii.iter)
            for i in range(self.nrVars):
                for ii in self.nbV[i]:
                    self._update_message(i, ii.iter)
        else:
            if (self.updates == 'SEQRND'):
                random.shuffle(self._update_seq)
            for e in self._update_seq:
                self._calc_new_message(e[0], e[1])
                self._update_message(e[0], e[1])
        max_diff = (- np.inf)
        for i in range(self.nrVars):
            b = self._belief_v(i).clone()
            max_diff = max(max_diff, dist_linf(b.p, self._oldBeliefsV[i].p))
            self._oldBeliefsV[i] = b
        for ii in range(self.nrFactors):
            b = self._belief_f(ii).clone()
            max_diff = max(max_diff, dist_linf(b.p, self._old_beliefs_f[ii].p))
            self._old_beliefs_f[ii] = b
        self._iters += 1
    if (max_diff > self._maxdiff):
        self._maxdiff = max_diff
    return max_diff