关于getActionNbghs函数
tangarfff opened this issue · 2 comments
你好,关于getActionNbghs这个函数的定义有些不太确定的地方。
梳理了一下getActionNbghs函数输入输出:
输入:矩阵,整数N
输出:整数N,整数N右邻居对应的值(邻居 >= 0)。
整数N,整数N(邻居 < 0)
getActionNbghs函数在JSSP_Env中的调用代码:
# adj matrix
precd, succd = self.getNghbs(action, self.opIDsOnMchs)
self.adj[action] = 0
self.adj[action, action] = 1
if action not in self.first_col:
self.adj[action, action - 1] = 1
self.adj[action, precd] = 1
self.adj[succd, action] = 1
所以getActionNbghs函数是想要获得下一个operation的值是吗?如果下一个operation<0, 说明下一个operation不能被开始对吗?为什么[action, precd] 和[succd, action]都要设置成1呢?
(A little tip for you that please ask the question in English such that others in the community can be benefit from your questions)
If I recall correctly, the functioning of getActionNbghs()
is to compute the machine successor and predecessor of a node, say 16
.
From the example I have provided in the code base:
if __name__ == '__main__':
opIDsOnMchs = np.array([[7, 29, 33, 16, -6, -6],
[6, 18, 28, 34, 2, -6],
[26, 31, 14, 21, 11, 1],
[30, 19, 27, 13, 10, -6],
[25, 20, 9, 15, -6, -6],
[24, 12, 8, 32, 0, -6]])
action = 16
precd, succd = getActionNbghs(action, opIDsOnMchs)
print(precd, succd)
If you run the program you will get:
33 16
That is, the machine predecesor of 16
is 33
, and the machine successor is itself 16
since there is no successor yet (refer to the matrix input opIDsOnMchs
, next number on the right of 16
is -1
, and -1
means no oeprations here)
The rest of the code:
precd, succd = self.getNghbs(action, self.opIDsOnMchs)
self.adj[action] = 0
self.adj[action, action] = 1
if action not in self.first_col:
self.adj[action, action - 1] = 1
self.adj[action, precd] = 1
self.adj[succd, action] = 1
they are just for adjusting the adjacent matrix that connects action
with the computed machine predecessor precd
and machine successor succd
.
Can reopen it if there is further questions regarding this issue.