コード例 #1
0
    def rout(self, start, desti, edge_desty, vedge_desty, nodes_order, U, G2,
             points, speed_dict):
        path = []
        Q, P_hat = [], []
        neigh = list(G2.successors(start))
        print('neigh %d' % len(neigh))
        start_ax = points[start]
        desti_ax = points[desti]
        s_d_arr = [desti_ax[0] - start_ax[0], desti_ax[1] - start_ax[1]]
        all_expire = 0.0

        def get_weight(p_hat):
            w_p_hat = {}
            if p_hat in edge_desty:
                w_p_hat = edge_desty[p_hat]
            elif p_hat in speed_dict:
                w_p_hat = speed_dict[p_hat]
            elif p_hat in vedge_desty:
                w_p_hat = vedge_desty[p_hat]
            return w_p_hat

        def get_maxP(w_p_, vv):
            p_max = 0.0
            for pk in w_p_:
                w_pk = w_p_[pk]
                pk_ = int(int(pk) / self.sigma)
                if int(pk) % self.sigma == 0: pk_ += 1
                p_max += float(w_pk) * U[vv][pk_]
            return p_max

        has_visit = set()
        has_visit.add(start)
        Que = PQDict.maxpq()
        Q = {}
        for vi in neigh:
            if vi in has_visit: continue
            else: has_visit.add(vi)
            p_hat = start + '-' + vi
            w_p_hat = get_weight(p_hat)
            w_min = min([float(l) for l in w_p_hat.keys()])
            p_order = nodes_order[vi]  #p_hat]
            tcost1 = time.time()
            inx_min = np.argwhere(U[vi] > 0)
            if len(inx_min) == 0:
                #print('u 0 vd: %s %s'%(vi, desti))
                continue
            inx_min = inx_min[0][0]
            all_expire += time.time() - tcost1
            cost_time = w_min + inx_min * self.sigma
            if cost_time <= self.T:
                tcost1 = time.time()
                p_max = get_maxP(w_p_hat, vi)
                all_expire += time.time() - tcost1
                Que[p_hat] = p_max
                Q[p_hat] = (p_max, w_p_hat, cost_time)
        #print('len Q %d'%len(Q))
        QQ = {}
        p_best_p, flag = 'none', False
        p_max_m, p_best_cost, p_w_p = -1, -1, -1
        if len(Q) == 0: return 'none1', -1, -1, -1, all_expire, -1
        all_rounds = 0
        while len(Q) != 0:
            (p_hat, pqv) = Que.popitem()
            all_rounds += 1
            (p_max, w_p_hat, cost_time) = Q[p_hat]
            del Q[p_hat]
            a = p_hat.rfind('-')
            v_l = p_hat[a + 1:]
            if v_l == desti:
                p_best_p = p_hat
                p_max_m = p_max
                p_best_cost = cost_time
                p_w_p = w_p_hat
                flag = True
                break
            neigh = list(G2.successors(v_l))
            cost_sv = min([float(l) for l in w_p_hat.keys()])
            vd_d_arr = [
                points[desti][0] - points[v_l][0],
                points[desti][1] - points[v_l][1]
            ]
            for u in neigh:
                if u == desti:
                    vu = v_l + '-' + u
                    w_vu = get_weight(vu)
                    if len(w_vu) == 0: cost_vu = 0
                    else: cost_vu = min([float(l) for l in w_vu.keys()])
                    tcost1 = time.time()
                    inx_min = np.argwhere(U[u] > 0)
                    inx_min = inx_min[0][0]
                    p_best_p = p_hat + ';' + vu
                    p_w_p = self.conv(w_p_hat, w_vu)
                    p_max_m = get_maxP(w_p_hat, u)
                    all_expire += time.time() - tcost1
                    p_best_cost = cost_sv + cost_vu + inx_min * self.sigma
                    flag = True
                    break
                if u in has_visit:
                    #print('u1 %s, vd %s'%(u, desti))
                    continue
                else:
                    has_visit.add(u)
                if u in p_hat:
                    #print('u2 %s, vd %s'%(u, desti))
                    continue
                vu = v_l + '-' + u
                w_vu = get_weight(vu)
                if len(w_vu) == 0:
                    #print('vu %s, vd %s'%(vu, desti))
                    continue
                cost_vu = min([float(l) for l in w_vu.keys()])
                p_order = nodes_order[u]  #p_hat]
                tcost1 = time.time()
                inx_min = np.argwhere(U[u] > 0)
                if len(inx_min) == 0:
                    #print('inx vu %s, vd %s'%(vu, desti))
                    continue
                inx_min = inx_min[0][0]
                all_expire += time.time() - tcost1
                cost_time = cost_sv + cost_vu + inx_min * self.sigma
                if cost_time <= self.T:
                    p_hat_p = p_hat + ';' + vu
                    w_p_hat_p = self.conv(w_p_hat, w_vu)
                    tcost1 = time.time()
                    p_hat_max = get_maxP(w_p_hat, u)
                    all_expire += time.time() - tcost1
                    QQ[p_hat_p] = (p_hat_max, w_p_hat_p, cost_time)
            if flag: break
            if len(Q) == 0:
                Q = copy.deepcopy(QQ)
                for qqk in QQ:
                    Que[qqk] = QQ[qqk][0]
                QQ = {}
        return p_best_p, p_max_m, p_best_cost, p_w_p, all_expire, all_rounds
コード例 #2
0
    def rout(self, start, desti, edge_desty, vedge_desty, nodes_order, U, G,
             points, pred):
        path = []
        Q, P_hat = [], []
        neigh = list(G.successors(start))
        print('neigh %d' % len(neigh))
        start_ax = points[start]
        desti_ax = points[desti]
        s_d_arr = [desti_ax[0] - start_ax[0], desti_ax[1] - start_ax[1]]
        all_expire2 = 0.0

        def get_weight(p_hat):
            w_p_hat = {}
            if p_hat in edge_desty:
                w_p_hat = edge_desty[p_hat]
            elif p_hat in vedge_desty:
                w_p_hat = vedge_desty[p_hat]
            return w_p_hat

        def get_maxP3(w_p_, vv, vi_getmin):
            p_max = 0.0
            for pk in w_p_:
                w_pk = w_p_[pk]
                pk_ = int(int(pk) / self.sigma)
                if int(pk) % self.sigma == 0: pk_ += 1
                if (1.0 * self.T - float(pk)) > vi_getmin:
                    p_max += float(w_pk)
            return p_max

        def get_vigetmin(vv):
            start1 = time.time()
            v = vv
            path_ = [v]
            while v != desti:
                v = pred[v]
                path_.append(v)
            spath = path_[0]
            vi_getmin = 0.0
            for epath in path_[1:]:
                key = spath + '-' + epath
                vi_getmin += min(abs(float(l)) for l in edge_desty[key].keys())
                spath = epath
            expire_time = time.time() - start1
            return vi_getmin, expire_time

        has_visit = set()
        has_visit.add(start)
        QQue = PQDict.maxpq()
        Q = {}
        for vi in neigh:
            if vi in has_visit: continue
            else: has_visit.add(vi)
            p_hat = start + '-' + vi
            w_p_hat = get_weight(p_hat)
            w_min = min([float(l) for l in w_p_hat.keys()])
            p_order = nodes_order[vi]  #p_hat]
            vi_getmin, ex_p = get_vigetmin(vi)
            all_expire2 += ex_p
            cost_time = w_min + vi_getmin

            if cost_time <= self.T:
                p_max = max(list(w_p_hat.values()))
                QQue[p_hat] = p_max
                Q[p_hat] = (p_max, w_p_hat, cost_time)
        print('len Q %d' % len(Q))
        QQ = {}
        p_best_p, flag = 'none', False
        p_max_m, p_best_cost, p_w_p = -1, -1, -1
        if len(Q) == 0: return 'none1', -1, -1, -1, all_expire2, -1
        all_rounds = 0
        while len(Q) != 0:
            (p_hat, pqv) = QQue.popitem()
            all_rounds += 1
            (p_max, w_p_hat, cost_time) = Q[p_hat]
            del Q[p_hat]
            a = p_hat.rfind('-')
            v_l = p_hat[a + 1:]
            if v_l == desti:
                p_best_p = p_hat
                p_max_m = p_max
                p_best_cost = cost_time
                p_w_p = w_p_hat
                flag = True
                break
            neigh = list(G.successors(v_l))
            cost_sv = min([float(l) for l in w_p_hat.keys()])
            vd_d_arr = [
                points[desti][0] - points[v_l][0],
                points[desti][1] - points[v_l][1]
            ]
            for u in neigh:
                if u == desti:
                    vu = v_l + '-' + u
                    w_vu = get_weight(vu)
                    if len(w_vu) == 0: cost_vu = 0
                    else: cost_vu = min([float(l) for l in w_vu.keys()])
                    vi_getmin, ex_p = get_vigetmin(u)
                    all_expire2 += ex_p
                    p_best_p = p_hat + ';' + vu
                    p_w_p = self.conv(w_p_hat, w_vu)
                    p_max_m = max(list(p_w_p.values()))
                    p_best_cost = cost_sv + cost_vu + vi_getmin  #inx_min*self.sigma
                    flag = True
                    break
                if u in has_visit:
                    #print('u1 %s'%u)
                    continue
                else:
                    has_visit.add(u)
                if u in p_hat:
                    #print('u2 %s'%u)
                    continue
                vu = v_l + '-' + u
                w_vu = get_weight(vu)
                if len(w_vu) == 0:
                    #print('vu %s'%vu)
                    continue
                cost_vu = min([float(l) for l in w_vu.keys()])
                p_order = nodes_order[u]  #p_hat]
                vi_getmin, ex_p = get_vigetmin(u)
                all_expire2 += ex_p
                cost_time = cost_sv + cost_vu + vi_getmin  #inx_min*self.sigma
                if cost_time <= self.T:
                    p_hat_p = p_hat + ';' + vu
                    w_p_hat_p = self.conv(w_p_hat, w_vu)
                    p_hat_max = max(list(w_p_hat_p.values()))
                    QQ[p_hat_p] = (p_hat_max, w_p_hat_p, cost_time)

            if flag: break
            if len(Q) == 0:
                Q = copy.deepcopy(QQ)
                for qqk in QQ:
                    QQue[qqk] = QQ[qqk][0]
                QQ = {}
        return p_best_p, p_max_m, p_best_cost, p_w_p, all_expire2, all_rounds
コード例 #3
0
    def rout(self, start, desti, edge_desty, vedge_desty, path_desty,
             nodes_order, U, G, points, speed_dict):
        all_expire = 0.0
        neigh = list(G.successors(start))
        has_visit = set()
        has_visit.add(start)
        Que = PQDict.maxpq()
        Q, QQ = {}, []
        print('neigh : %d' % len(neigh))
        for vi in neigh:
            if vi in has_visit: continue
            else: has_visit.add(vi)
            candidite = start + '-' + vi
            if candidite in edge_desty:
                w_can = edge_desty[candidite]
            elif candidite in speed_dict:
                w_can = speed_dict[candidite]
            elif candidite in vedge_desty:
                w_can = vedge_desty[candidite]
            w_min = min([float(l) for l in w_can.keys()])
            w_exp = 0.0
            for w_k, w_v in w_can.items():
                w_exp += float(w_k) * float(w_v)
            if w_min <= self.T:
                Que[candidite] = w_exp
                Q[candidite] = w_can
        Qkey = list(Q.keys())
        flag = False
        best_path, best_w = None, -1
        bts = time.time()
        all_rounds = 0
        while len(Q) != 0:
            (cand, pqv) = Que.popitem()
            all_rounds += 1
            w_can = Q[cand]
            del Q[cand]
            a = cand.rfind('-')
            v_l = cand[a + 1:]
            if v_l == desti:
                best_path = cand
                best_w = w_can
                flag = True
                break
            if desti in cand:
                a = cand.find('-' + desti)
                best_path = cand[:a + len(desti) + 1]
                best_w = w_can
                flag = True
                break
            neigh = list(G.successors(v_l))
            for u in neigh:
                if u == desti:
                    next_cand = v_l + '-' + u
                    if next_cand in edge_desty:
                        next_w = edge_desty[next_cand]
                    elif next_cand in speed_dict:
                        next_w = speed_dict[next_cand]
                    elif next_cand in vedge_desty:
                        next_w = vedge_desty[next_cand]
                    tcost1 = time.time()
                    next_w_min = min([float(l) for l in next_w.keys()])
                    best_path = cand + ';' + next_cand
                    best_w = self.conv(w_can, next_w)
                    all_expire += time.time() - tcost1
                    flag = True
                    break
                if u in has_visit: continue
                else: has_visit.add(u)
                if u in cand: continue
                next_cand = v_l + '-' + u
                if next_cand in vedge_desty:
                    next_w = vedge_desty[next_cand]
                elif next_cand in edge_desty:
                    next_w = edge_desty[next_cand]
                elif next_cand in speed_dict:
                    next_w = speed_dict[next_cand]

                next_w_min = min([float(l) for l in next_w.keys()])
                if next_w_min <= self.T:
                    new_path = cand + ';' + next_cand
                    temp_1 = cand.rfind(';')
                    if temp_1 != -1:
                        new_p = cand[temp_1 + 1:] + ';' + next_cand
                        if new_p in path_desty:
                            new_path_w = self.path_conv(
                                w_can, path_desty[new_p], cand[tep_1 + 1:],
                                edge_desty)
                        else:
                            new_path_w = self.conv(w_can, next_w)
                    else:
                        new_path_w = self.conv(w_can, next_w)

                    w_exp = 0.0
                    for w_k, w_v in w_can.items():
                        w_exp += float(w_k) * float(w_v)
                    QQ.append((new_path, new_path_w, w_exp))
            last_edge = self.get_last_edge(cand)
            if flag: break
            if len(Q) == 0:
                for QQ_ in QQ:
                    Q[QQ_[0]] = QQ_[1]
                    Que[QQ_[0]] = QQ_[2]
        return best_path, best_w, all_rounds, all_expire
コード例 #4
0
    def rout(self, start, desti, edge_desty, vedge_desty, speed_dict, nodes_order, U, G, points):
        path = []
        Q, P_hat = [], []
        neigh = list(G.successors(start))
        print('neigh %d'%len(neigh))
        start_ax = points[start]
        desti_ax = points[desti]
        s_d_arr = [desti_ax[0] - start_ax[0], desti_ax[1] - start_ax[1]]
        all_expire = 0.0
        start1 = time.time() 
        def get_weight(p_hat):
            w_p_hat = {}
            if p_hat in edge_desty:
                w_p_hat = edge_desty[p_hat]
            elif p_hat in speed_dict:
                w_p_hat = speed_dict[p_hat]
            elif p_hat in vedge_desty:
                w_p_hat = vedge_desty[p_hat]
            return w_p_hat

        def get_maxP(w_p_, vv):
            p_max = 0.0
            for pk in w_p_:
                w_pk = w_p_[pk]
                pk_ = int(int(pk) / self.sigma)
                if int(pk) % self.sigma == 0: pk_ += 1
                p_max += float(w_pk ) * U[vv][pk_]
            return p_max

        def get_maxP2(w_p_, vv):
            p_max = 0.0 
            start1 = time.time() 
            vi_getmin = self.get_distance(points, (vv, desti)) / self.speed * 3600
            for pk in w_p_:
                w_pk = w_p_[pk]
                pk_ = int(int(pk) / self.sigma)
                if int(pk) % self.sigma == 0: pk_ += 1
                if (1.0*self.T - float(pk)) > vi_getmin:
                    p_max += float(w_pk)
            all_expire += time.time() - start1
            return p_max

        has_visit = set()
        has_visit.add(start)
        Que = PQDict.maxpq()
        Q = {}
        print('T: %f'%self.T)
        for vi in neigh:
            if vi in has_visit: continue
            else: has_visit.add(vi)
            p_hat = start +'-'+ vi
            w_p_hat = get_weight(p_hat)
            w_min = min([float(l) for l in w_p_hat.keys()])
            p_order = nodes_order[vi] #p_hat]
            start1 = time.time() 
            vi_getmin = self.get_distance(points, (vi, desti)) / self.speed * 3600
            all_expire += time.time() - start1
            cost_time = w_min + vi_getmin
            if cost_time <= self.T:
                p_max = max(list(w_p_hat.values()))
                Que[p_hat] = p_max
                Q[p_hat] = (p_max, w_p_hat, cost_time)
        print('len Q %d'%len(Q))
        QQ = {}
        p_best_p, flag, p_max_m, p_best_cost, p_w_p = 'none', False, -1, -1, -1
        if len(Q) == 0: return 'none1', -1, -1, -1, all_expire, -1
        all_counts = 0
        while len(Q) != 0:
            (p_hat, pqv) = Que.popitem()
            all_counts += 1
            (p_max, w_p_hat, cost_time) = Q[p_hat]
            del Q[p_hat]
            a = p_hat.rfind('-')
            v_l = p_hat[a+1:]
            if v_l == desti:
                p_best_p = p_hat
                p_max_m = p_max
                p_best_cost = cost_time
                p_w_p = w_p_hat
                flag = True
                break
            neigh = list(G.successors(v_l))
            cost_sv = min([float(l) for l in w_p_hat.keys()])
            vd_d_arr = [points[desti][0]-points[v_l][0], points[desti][1]-points[v_l][1]]
            for u in neigh:
                if u == desti:
                    vu = v_l + '-' + u
                    w_vu = get_weight(vu)
                    if len(w_vu) == 0: cost_vu = 0
                    else: cost_vu = min([float(l) for l in w_vu.keys()])
                    start1 = time.time() 
                    vi_getmin = self.get_distance(points, (u, desti)) / self.speed * 3600
                    all_expire += time.time() - start1
                    p_best_p = p_hat + ';' + vu
                    p_w_p = self.conv(w_p_hat, w_vu)
                    p_max_m = max(list(p_w_p.values()))
                    p_best_cost = cost_sv + cost_vu + vi_getmin#inx_min*self.sigma
                    flag = True
                    break
                if u in has_visit: 
                    #print('u1 %s'%u)
                    continue
                else: has_visit.add(u)
                if u in p_hat: 
                    #print('u2 %s'%u)
                    continue
                vu = v_l + '-' + u
                w_vu = get_weight(vu)
                if len(w_vu) == 0:
                    #print('vu %s'%vu)
                    continue
                cost_vu = min([float(l) for l in w_vu.keys()])
                p_order = nodes_order[u] #p_hat]
                start1 = time.time() 
                vi_getmin = self.get_distance(points, (u, desti)) / self.speed * 3600
                all_expire += time.time() - start1
                cost_time = cost_sv + cost_vu + vi_getmin#inx_min*self.sigma
                if cost_time <= self.T:
                    p_hat_p = p_hat + ';' + vu
                    w_p_hat_p = self.conv(w_p_hat, w_vu)
                    p_hat_max = max(list(w_p_hat_p.values()))
                    QQ[p_hat_p] = (p_hat_max, w_p_hat_p, cost_time)
            if flag: break
            if len(Q) == 0:

                Q = copy.deepcopy(QQ)
                for qqk in QQ:
                    Que[qqk] = QQ[qqk][0]
                QQ = {}
        return p_best_p, p_max_m, p_best_cost, p_w_p, all_expire, all_counts
コード例 #5
0
    def rout(self, start, desti, edge_desty, vedge_desty, nodes_order, U, G,
             G2, points, gt_path, gt_path_, pred):
        Q, P_hat = [], []
        neigh = list(G.successors(start))
        print('neigh %d' % len(neigh))
        start_ax = points[start]
        desti_ax = points[desti]
        s_d_arr = [desti_ax[0] - start_ax[0], desti_ax[1] - start_ax[1]]
        all_expire2 = 0.0

        def get_weight(p_hat):
            w_p_hat = {}
            if p_hat in edge_desty:
                w_p_hat = edge_desty[p_hat]
            elif p_hat in gt_path:
                w_p_hat = gt_path[p_hat][1]
            elif p_hat in vedge_desty:
                w_p_hat = vedge_desty[p_hat]
                #print('vedge %s' %p_hat)
            else:
                print('other %s' % p_hat)
            if len(w_p_hat) == 0:
                print('zero %s' % p_hat)
            return w_p_hat

        def get_maxP3(w_p_, vv, vi_getmin):
            p_max = 0.0
            for pk in w_p_:
                w_pk = w_p_[pk]
                pk_ = int(int(pk) / self.sigma)
                if int(pk) % self.sigma == 0: pk_ += 1
                if (1.0 * self.T - float(pk)) > vi_getmin:
                    p_max += float(w_pk)
            return p_max

        def get_vigetmin2(vv):
            start2 = time.time()
            v = vv
            path_ = [v]
            while v != desti:
                v = pred[v]  #[2]
                path_.append(v)
            paths_ = []
            if len(path_) == 2: paths_ = [path_[0] + '-' + path_[1]]
            else:
                paths_ = [
                    path_[i - 1] + '-' + path_[i]
                    for i in range(1, len(path_))
                ]
            spath = path_[0]
            vi_getmin = 0.0
            flag, iters = False, -1
            for l in range(len(paths_)):
                key = ';'.join(p for p in paths_[l:])
                if key in gt_path_:
                    vi_getmin += min(
                        abs(float(ll)) for ll in gt_path_[key].keys())
                    flag = True
                    iters = 0
                    break
            if not flag:
                for l in range(len(paths_), 1, -1):
                    key = ';'.join(p for p in paths_[:l + 1])
                    if key in gt_path_:
                        vi_getmin += min(
                            abs(float(ll)) for ll in gt_path_[key].keys())
                        flag = True
                        iters = 1
                        break
            if not flag:
                s = 0
                l = len(path_)
            else:
                if iters == 0:
                    s = 0
                    l = l
                elif iters == 1:
                    s = l + 1
                    l = len(paths_)
                #print('got shot')
            for key in paths_[s:l]:
                #key = spath+'-'+epath
                if key in edge_desty:
                    vi_getmin += min(
                        abs(float(ll)) for ll in edge_desty[key].keys())
                elif key in vedge_desty:
                    vi_getmin += min(
                        abs(float(ll)) for ll in vedge_desty[key].keys())
                else:
                    vi_getmin += min(
                        abs(float(ll)) for ll in gt_path[key][1].keys())
            expire_time = time.time() - start2
            return vi_getmin, expire_time

        has_visit = set()
        has_visit.add(start)
        Que = PQDict.maxpq()
        Q = {}
        for vi in neigh:
            if vi in has_visit: continue
            else: has_visit.add(vi)
            p_hat = start + '-' + vi
            w_p_hat = get_weight(p_hat)
            w_min = min([float(l) for l in w_p_hat.keys()])
            p_order = nodes_order[vi]  #p_hat]
            vi_getmin, ex_p = get_vigetmin2(vi)
            all_expire2 += ex_p
            cost_time = w_min + vi_getmin
            if cost_time <= self.T:
                p_max = get_maxP3(w_p_hat, vi, vi_getmin)
                Que[p_hat] = p_max
                Q[p_hat] = (p_max, w_p_hat, cost_time)
        print('len Q %d' % len(Q))
        QQ = {}
        p_best_p, flag = None, False
        p_best_p, p_max_m, p_best_cost, p_w_p = None, -1, -1, -1
        if len(Q) == 0: return None, -1, -1, -1, all_expire2, -1
        all_rounds = 0
        while len(Q) != 0:
            (p_hat, pqv) = Que.popitem()
            all_rounds += 1
            (p_max, w_p_hat, cost_time) = Q[p_hat]
            del Q[p_hat]
            a = p_hat.rfind('-')
            v_l = p_hat[a + 1:]
            if v_l == desti:
                p_best_p = p_hat
                p_max_m = p_max
                p_best_cost = cost_time
                p_w_p = w_p_hat
                flag = True
                break
            neigh = list(G.successors(v_l))
            if len(w_p_hat.keys()) == 0:
                print(w_p_hat)
                print(p_hat)
            cost_sv = min([float(l) for l in w_p_hat.keys()])
            vd_d_arr = [
                points[desti][0] - points[v_l][0],
                points[desti][1] - points[v_l][1]
            ]
            for u in neigh:
                if u == desti:
                    vu = v_l + '-' + u
                    w_vu = get_weight(vu)
                    if len(w_vu) == 0: cost_vu = 0
                    else: cost_vu = min([float(l) for l in w_vu.keys()])
                    vi_getmin, ex_p = get_vigetmin2(u)
                    all_expire2 += ex_p
                    p_best_p = p_hat + ';' + vu
                    p_w_p = self.conv(w_p_hat, w_vu)
                    p_max_m = get_maxP3(w_p_hat, u, vi_getmin)
                    p_best_cost = cost_sv + cost_vu + vi_getmin  #inx_min*self.sigma
                    flag = True
                    break
                if u in has_visit:
                    #print('u1 %s'%u)
                    continue
                else:
                    has_visit.add(u)
                if u in p_hat:
                    #print('u2 %s'%u)
                    continue
                vu = v_l + '-' + u
                w_vu = get_weight(vu)
                if len(w_vu) == 0:
                    #print('vu %s'%vu)
                    continue
                cost_vu = min([float(l) for l in w_vu.keys()])
                p_order = nodes_order[u]  #p_hat]
                vi_getmin, ex_p = get_vigetmin2(u)
                all_expire2 += ex_p
                cost_time = cost_sv + cost_vu + vi_getmin  #inx_min*self.sigma
                if cost_time <= self.T:
                    p_hat_p = p_hat + ';' + vu
                    w_p_hat_p = self.conv(w_p_hat, w_vu)
                    p_hat_max = get_maxP3(w_p_hat, u, vi_getmin)
                    QQ[p_hat_p] = (p_hat_max, w_p_hat_p, cost_time)
            if flag: break
            if len(Q) == 0:
                Q = copy.deepcopy(QQ)
                for qqk in QQ:
                    Que[qqk] = QQ[qqk][0]
                QQ = {}
        return p_best_p, p_max_m, p_best_cost, p_w_p, all_expire2, all_rounds