本文整理汇总了Python中Input.exp_random方法的典型用法代码示例。如果您正苦于以下问题:Python Input.exp_random方法的具体用法?Python Input.exp_random怎么用?Python Input.exp_random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input.exp_random方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import Input [as 别名]
# 或者: from Input import exp_random [as 别名]
def run():
# ===========================================================================
# STEP0
# initialize
# make all node and connect nodes by edges
# ===========================================================================
# jobs, qcs, ycs, yts, yt_operation_time = Input.exp_not_random()
jobs, qcs, ycs, yts, yt_operation_time = Input.exp_random()
print "yt_operation_time : ", [(k[0].id, k[1].id, v) for k, v in yt_operation_time.items()]
not_yet_used_yt = yts[:]
all_nodes = []
possible_planable_n = []
# ===========================================================================
# make nodes related with job
# ===========================================================================
for job in jobs:
maked_nodes = tuple([Node(job.id, i) for i in range(4)])
target_qc = None
target_yc = None
for qc in qcs:
if job in qc.job_sequence:
target_qc = qc
for yc in ycs:
if job in yc.job_list:
target_yc = yc
if job.state == "discharging":
Edge(maked_nodes[0], maked_nodes[1], target_qc, Input.qc_discharging_operation)
Edge(maked_nodes[1], maked_nodes[2], None, yt_operation_time[(target_qc, target_yc)])
Edge(maked_nodes[2], maked_nodes[3], target_yc, Input.yc_discharging_operation)
else:
Edge(maked_nodes[0], maked_nodes[1], target_yc, Input.yc_loading_operation)
Edge(maked_nodes[1], maked_nodes[2], None, yt_operation_time[(target_qc, target_yc)])
Edge(maked_nodes[2], maked_nodes[3], target_qc, Input.qc_loading_operation)
job.nodes = maked_nodes
# ===========================================================================
# append all node in all_nodes
# ===========================================================================
for j in jobs:
all_nodes.extend(j.nodes)
# ===========================================================================
# connect nodes related with qcs
# ===========================================================================
for qc in qcs:
for i in range(1, len(qc.job_sequence)):
prev_j = qc.job_sequence[i - 1]
current_j = qc.job_sequence[i]
target_start_n = None
target_end_n = None
ready_time = None
if prev_j.state == "discharging":
target_start_n = jobs[prev_j.id].nodes[1]
if current_j.state == "discharging":
target_end_n = jobs[current_j.id].nodes[0]
ready_time = Input.qc_ready_t_d_d
else:
target_end_n = jobs[current_j.id].nodes[2]
ready_time = Input.qc_ready_t_d_l
else:
target_start_n = jobs[prev_j.id].nodes[3]
if current_j.state == "discharging":
target_end_n = jobs[current_j.id].nodes[0]
ready_time = Input.qc_ready_t_l_d
else:
target_end_n = jobs[current_j.id].nodes[2]
ready_time = Input.qc_ready_t_l_l
Edge(target_start_n, target_end_n, qc.id, ready_time)
# ===========================================================================
# initialize nodes related with qcs
# and make possible_planable_n
# ===========================================================================
for j in jobs:
if j.state == "loading":
j.nodes[2].planed = True
j.nodes[3].planed = True
possible_planable_n.append(j.nodes[0])
else:
j.nodes[0].planed = True
for qc in qcs:
if not qc.job_sequence:
continue
# print qc.job_sequence
qc_start_n = qc.job_sequence[0].nodes[0]
for e in qc_start_n.outgoings:
if isinstance(e.vehicle, QC):
possible_planable_n.append(e.end_n)
print "qcs"
for qc in qcs:
print " qc id : ", qc.id, "sequence : ", [(x.id, x.state) for x in qc.job_sequence],
print ""
print "ycs"
for yc in ycs:
print " yc id : ", yc.id, "sequence : ", [(x.id, x.state) for x in yc.job_list],
print ""
count = 0
while possible_planable_n:
#.........这里部分代码省略.........