-
Notifications
You must be signed in to change notification settings - Fork 156
/
parameters.py
executable file
·88 lines (62 loc) · 3.71 KB
/
parameters.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import numpy as np
import math
import job_distribution
class Parameters:
def __init__(self):
self.output_filename = 'data/tmp'
self.num_epochs = 10000 # number of training epochs
self.simu_len = 10 # length of the busy cycle that repeats itself
self.num_ex = 1 # number of sequences
self.output_freq = 10 # interval for output and store parameters
self.num_seq_per_batch = 10 # number of sequences to compute baseline
self.episode_max_length = 200 # enforcing an artificial terminal
self.num_res = 2 # number of resources in the system
self.num_nw = 5 # maximum allowed number of work in the queue
self.time_horizon = 20 # number of time steps in the graph
self.max_job_len = 15 # maximum duration of new jobs
self.res_slot = 10 # maximum number of available resource slots
self.max_job_size = 10 # maximum resource request of new work
self.backlog_size = 60 # backlog queue size
self.max_track_since_new = 10 # track how many time steps since last new jobs
self.job_num_cap = 40 # maximum number of distinct colors in current work graph
self.new_job_rate = 0.7 # lambda in new job arrival Poisson Process
self.discount = 1 # discount factor
# distribution for new job arrival
self.dist = job_distribution.Dist(self.num_res, self.max_job_size, self.max_job_len)
# graphical representation
assert self.backlog_size % self.time_horizon == 0 # such that it can be converted into an image
self.backlog_width = int(math.ceil(self.backlog_size / float(self.time_horizon)))
self.network_input_height = self.time_horizon
self.network_input_width = \
(self.res_slot +
self.max_job_size * self.num_nw) * self.num_res + \
self.backlog_width + \
1 # for extra info, 1) time since last new job
# compact representation
self.network_compact_dim = (self.num_res + 1) * \
(self.time_horizon + self.num_nw) + 1 # + 1 for backlog indicator
self.network_output_dim = self.num_nw + 1 # + 1 for void action
self.delay_penalty = -1 # penalty for delaying things in the current work screen
self.hold_penalty = -1 # penalty for holding things in the new work screen
self.dismiss_penalty = -1 # penalty for missing a job because the queue is full
self.num_frames = 1 # number of frames to combine and process
self.lr_rate = 0.001 # learning rate
self.rms_rho = 0.9 # for rms prop
self.rms_eps = 1e-9 # for rms prop
self.unseen = False # change random seed to generate unseen example
# supervised learning mimic policy
self.batch_size = 10
self.evaluate_policy_name = "SJF"
def compute_dependent_parameters(self):
assert self.backlog_size % self.time_horizon == 0 # such that it can be converted into an image
self.backlog_width = self.backlog_size / self.time_horizon
self.network_input_height = self.time_horizon
self.network_input_width = \
(self.res_slot +
self.max_job_size * self.num_nw) * self.num_res + \
self.backlog_width + \
1 # for extra info, 1) time since last new job
# compact representation
self.network_compact_dim = (self.num_res + 1) * \
(self.time_horizon + self.num_nw) + 1 # + 1 for backlog indicator
self.network_output_dim = self.num_nw + 1 # + 1 for void action