當前位置: 首頁>>代碼示例>>Python>>正文


Python Input.exp_random方法代碼示例

本文整理匯總了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:
#.........這裏部分代碼省略.........
開發者ID:jerryhan88,項目名稱:jerry-lab,代碼行數:103,代碼來源:LeeHa.py


注:本文中的Input.exp_random方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。