"Torflow measurements scaling with PID control (Per relay scaled bandwidth)."initialize measurements from previous Bandwidth Fileprev_votes = VoteSet()tot_net_bw = 0for every measurementIntialize ratios and pid_errorn.fbw_ratio = n.filt_bw/true_filt_avg[n.node_class()]n.sbw_ratio = n.strm_bw/true_strm_avg[n.node_class()]n.use_bw = n.desc_bwif n.sbw_ratio > n.fbw_ratio:1.assert cs_junk.use_best_ratio == Truen.pid_error = (n.strm_bw - true_strm_avg[n.node_class()])/ true_strm_avg[n.node_class()]else:n.pid_error = (n.filt_bw - true_filt_avg[n.node_class()])/ true_filt_avg[n.node_class()]0 <= n.pid_error <= 500.0n.pid_error = max(bwstrm_i / bwstrm, bwfilt_i / bwfilt) - 1n.idhex in prev_votes.vote_map?yesnoif n.measured_at >prev_votes.vote_map[n.idhex].measured_at;measurement newer?yesnoif n.idhex in prev_consensusand ("Guard" in prev_consensus[n.idhex].flags=if n.idhex not in prev_votes.vote_mapor n.measured_at - prev_votes.vote_map[n.idhex].measured_at> cs_junk.guard_sample_rate:# cs_jung.guard_sample_rate = 2*7*24*60*60 # 2wksnot exit diff NOT bigger than 2 weeksyesno\# Use new measurement but not feedbackn.copy_vote(prev_vote.vote_map[n.idhex]));n.new_bw = n.get_pid_bw(prev_votes.vote_map[n.idhex],cs_junk.K_p,cs_junk.K_i,cs_junk.K_d,0.0, False)\# self.new_bw = vote.bw * 1000self.pid_bw = vote.pid_bwself.pid_error_sum = vote.pid_error_sumself.pid_delta = vote.pid_deltan.new_bw = self.use_bw + self.use_bw * self_pid_errorn.measured_at = prev_vote.measured_atn.pid_error = prev_vote.pid_error1.full feedbackn.new_bw = n.get_pid_bw(prev_votes.vote_map[n.idhex],cs_junk.K_p,cs_junk.K_i,cs_junk.K_d,cs_junk.K_i_decay)= n.get_pid_bw(prev_votes.vote_map[n.idhex],1.0, 0, 0, 0)self.prev_error = prev_vote.pid_errorself.pid_bw = self.use_bw+ self.use_bw * self.pid_error# + self.desc_bw * self.pid_errorself.pid_error_sum = 0 + self.pid_errorn.new_bw = self.pid_bwyesin prev_consensus,is guard?\# Reset values. Don't vote/sample this measurement round.\# is in the previous bwfile, but haven't check the consensusn.revert_to_vote(prev_votes.vote_map[n.idhex])\# which calls again self.copy_vote(vote)self.new_bw = prev_vote.bw*1000self.pid_bw = prev_vote.pid_bwself.pid_error_sum = prev_vote.pid_error_sumself.pid_delta = prev_vote.pid_deltaself.pid_error = vote.pid_errorself.measured_at = vote.measured_atn.new_bw = n.use_bw + n.use_bw * n.pid_errorn.pid_error_sum = n.pid_errorn.pid_bw = n.new_bwprev_consensus[n.idhex].measured = Truetot_net_bw += n.new_bwyesprev_consensus[n.idhex].bandwidth != Noneyesn.idhex in prev_consensusfor n in nodes.itervalues()?cap...for n in nodes.itervalues()?