def __make_prev_rank(self): for node_id, val in list(self.working_vec.items()): try: computing, requesting = val except (TypeError, ValueError): logger.warning("Wrong trust vector element {}".format(val)) break comp_trust = util.vec_to_trust(computing) req_trust = util.vec_to_trust(requesting) self.prevRank[node_id] = [comp_trust, req_trust]
def __save_working_vec(self): for node_id, val in list(self.working_vec.items()): try: computing, requesting = val except (TypeError, ValueError): logger.warning("Wrong trust vector element {}".format(val)) break comp_trust = util.vec_to_trust(computing) req_trust = util.vec_to_trust(requesting) dm.upsert_global_rank(node_id, comp_trust, req_trust, computing[1], requesting[1])
def __compare_working_vec_and_prev_rank(self): aggregated_trust = 0.0 for node_id, val in list(self.working_vec.items()): try: computing, requesting = val except (TypeError, ValueError): logger.warning("Wrong trust vector element {}".format(val)) break comp_trust = util.vec_to_trust(computing) req_trust = util.vec_to_trust(requesting) if node_id in self.prevRank: comp_trust_old = self.prevRank[node_id][0] req_trust_old = self.prevRank[node_id][1] else: comp_trust_old, req_trust_old = 0, 0 aggregated_trust += abs(comp_trust - comp_trust_old) aggregated_trust += abs(req_trust - req_trust_old) return aggregated_trust