-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtau_scheduler.py
39 lines (33 loc) · 1.26 KB
/
tau_scheduler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class TauScheduler:
def __init__(self, origin_tau, mini_tau, n_step, s_step=0):
self.origin_tau = origin_tau
self.mini_tau = mini_tau
self.n_step = n_step
self.s_step = s_step
self.step_interval = (self.mini_tau - self.origin_tau) / self.n_step
def step_on(self, advance=False):
if advance:
self.s_step += 1
if self.s_step >= self.n_step:
return self.mini_tau
return self.s_step * self.step_interval + self.origin_tau
def dump(self):
self_dict = {
"origin_tau": self.origin_tau,
"mini_tau": self.mini_tau,
"n_step": self.n_step,
"s_step": self.s_step,
}
return self_dict
@staticmethod
def load(self_dict):
return TauScheduler(self_dict["origin_tau"],
self_dict["mini_tau"],
self_dict["n_step"],
self_dict["s_step"])
def self_load(self, self_dict):
self.origin_tau = self_dict["origin_tau"]
self.mini_tau = self_dict["mini_tau"]
self.n_step = self_dict["n_step"]
self.s_step = self_dict["s_step"]
self.step_interval = (self.mini_tau - self.origin_tau) / self.n_step