def post_discover(self, s, terminal, a, td_error, phi_s, rho=1):
        self.t += 1
        discovered = 0
        plus = self.random_state.rand() >= self.kappa
        # if self.t == 22:
        #    import ipdb; ipdb.set_trace()
        activeFeatures = phi_s.nonzero()[
                                       0]  # Indices of non-zero elements of vector phi_s
        # print "Active Features:", activeFeatures, phi_s
        if not self.lazy:
            dd = defaultdict(float)
            for g_index, h_index in combinations(activeFeatures, 2):
                # create potential if necessary
                dd[self.get_potential(g_index, h_index).f_set] = phi_s[g_index] * phi_s[h_index]

            for f, potential in self.iFDD_potentials.items():
                potential.update_statistics(
                    rho, td_error, self.lambda_, self.discount_factor, dd[f], self.n_rho)
                # print plus, potential.relevance(plus=plus)
                if potential.relevance(plus=plus) >= self.discovery_threshold:
                    self.addFeature(potential)
                    del self.iFDD_potentials[f]
                    discovered += 1
            # print "t", self.t, "td_error", td_error, discovered
            # self.showCache()
            # print [ f.f_set for f in self.sortediFDDFeatures.toList()]
            # self.showPotentials()

            return discovered

        for g_index, h_index in combinations(activeFeatures, 2):
            discovered += self.inspectPair(g_index, h_index, td_error, phi_s, rho, plus)

        if rho > 0:
            self.w += np.log(rho)
        else:
            # cut e-traces
            self.n_rho += 1
            self.w = 0
            self.t_rho[self.n_rho] = self.t
        # "rescale" to avoid numerical problems
        # if self.t_rho[self.n_rho] + 300 < self.t:
        #    self.y_a[self.n_rho] *= (self.discount_factor * self.lambda_) ** (-300)
        #    self.y_b[self.n_rho] *= (self.discount_factor * self.lambda_) ** (-300)
        #    self.t_rho[self.n_rho] += 300
        if self.lambda_ > 0:
            self.y_a[self.n_rho] += np.exp(self.w) * (self.discount_factor * self.lambda_) ** (
                self.t - self.t_rho[self.n_rho]) * np.abs(td_error)
            self.y_b[self.n_rho] += np.exp(self.w) * (self.discount_factor * self.lambda_) ** (
                self.t - self.t_rho[self.n_rho]) * td_error
            assert(np.isfinite(self.y_a[self.n_rho]))
            assert(np.isfinite(self.y_b[self.n_rho]))

        # print "t", self.t, "td_error", td_error, discovered
        # self.showCache()
        # print [ f.f_set for f in self.sortediFDDFeatures.toList()]
        # self.showPotentials()
        return discovered
Run the git-http-backend server in a new thread.
dataset/ETHPy150Open rlpy/rlpy/rlpy/Representations/iFDD.py/iFDDK.post_discover--crossover with--dataset/ETHPy150Open dubiousjim/yagh/src/remote-hg.py/GitHttpBackend.start