Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run the manhattan data? #14

Open
LuckyLeeLL opened this issue Jan 10, 2022 · 10 comments
Open

How to run the manhattan data? #14

LuckyLeeLL opened this issue Jan 10, 2022 · 10 comments

Comments

@LuckyLeeLL
Copy link

How to modify the parameters to run the manhattan data?
I try to adjust the road_net and the volum, but the 'json' file without NUM_COL and NUM_ROW.

Thank you very much.

@MPHarryZhang
Copy link

How to modify the parameters to run the manhattan data? I try to adjust the road_net and the volum, but the 'json' file without NUM_COL and NUM_ROW.

Thank you very much.

Hello, I am also facing the same problem. Could you please tell me if you have solved it? Thank you very much.

@jianghaoyuan1994
Copy link

Same problem

@WaterFountain-Jack
Copy link

Same problem,has anyone solve it?

@LiangZhang1996
Copy link

I have read the json files of Manhattan in deatails, and the traffic network is not a regular pattern.
Therefore, just use NUM_COL and NUM_ROW can describe it.

Additionally, the intersections under Manhattan also different from each other, rather than a 4-way 4-phase intersection.
And the current file and model cannot support running under Manhattan.

In summary, it is impossible to train and test models under Manhattan, unless you design a unified neural network like AttendLight.

@WaterFountain-Jack
Copy link

Thank you for your answer!

@BackMountainDevil
Copy link

hello, guys. intersection number in MPLight/data/manhattan/manhattan.json just 1 while tsc says "The road network contains 2510 intersections in Manhattan". other files like manhattan_*.json are just flowFile not roadnetFile. so why the roadnetFile just contain 1 intersection?

@BackMountainDevil
Copy link

my mistake. 1 intersections can contains all intersection. I got it. sorry to borther you guys.

@WaterFountain-Jack
Copy link

my mistake. 1 intersections can contains all intersection. I got it. sorry to borther you guys.
Great answer, thank you very much!

@BackMountainDevil
Copy link

I count the different intersection with diff phase and got some wired data: {1: 1421, 2: 1459, 3: 16, 4: 6, 8: 678, 9: 182, 10: 1}. The amount of them is 3763. If the time of lightphases is 0, I just cut it off when counting

  1. paper say there is 2510 traffic lights, I count the not virtual intersection num is 3763. Am I counting wrong?
  2. The number of traffic light with only 1 phase is 1421, such as cluster_5333189427_5333189428. I wonder if only 1 phase, why would it need to be controned? I think those which >=2 should be control.
def parse_roadnet(roadnetFile):
    roadnet = json.load(open(roadnetFile))
    lane_phase_info_dict ={}

    # many intersections exist in the roadnet and virtual intersection is controlled by signal
    for intersection in roadnet["intersections"]:
        if intersection['virtual']:
            continue
        lane_phase_info_dict[intersection['id']] = {"location": {
                                                    "x": float(intersection["point"]["x"]),
                                                    "y": float(intersection["point"]["y"]),},
                                                    "start_lane": [],
                                                    "end_lane": [],
                                                    "phase": [],
                                                    "phase_startLane_mapping": {},
                                                    "phase_roadLink_mapping": {},
                                                     
                                                }
        road_links = intersection["roadLinks"]

        start_lane = []
        end_lane = []
        roadLink_lane_pair = {ri: [] for ri in
                              range(len(road_links))}  # roadLink includes some lane_pair: (start_lane, end_lane)

        for ri in range(len(road_links)):
            road_link = road_links[ri]
            for lane_link in road_link["laneLinks"]:
                sl = road_link['startRoad'] + "_" + str(lane_link["startLaneIndex"])
                el = road_link['endRoad'] + "_" + str(lane_link["endLaneIndex"])
                start_lane.append(sl)
                end_lane.append(el)
                roadLink_lane_pair[ri].append((sl, el))

        lane_phase_info_dict[intersection['id']]["start_lane"] = sorted(list(set(start_lane)))
        lane_phase_info_dict[intersection['id']]["end_lane"] = sorted(list(set(end_lane)))

        # ["trafficLight"]["lightphases"] 中的长度并不一定等于红绿灯的全部相位,比如生成脚本的第一个相位就是全红,只允许右转,还有的是该相位的时间为0,manhattan中就有不少是availableRoadLinks和time都是0的情况
        phase_i = 0
        start_index= 0 # 设置为1来跳过第一个红灯相位
        for _ in range(start_index, len(intersection["trafficLight"]["lightphases"])):  
            p = intersection["trafficLight"]["lightphases"][phase_i]
            if p['time']<=0:
                continue
            lane_pair = []
            start_lane = []
            for ri in p["availableRoadLinks"]:
                lane_pair.extend(roadLink_lane_pair[ri])
                if roadLink_lane_pair[ri][0][0] not in start_lane:
                    start_lane.append(roadLink_lane_pair[ri][0][0])
            lane_phase_info_dict[intersection['id']]["phase"].append(phase_i)
            lane_phase_info_dict[intersection['id']]["phase_startLane_mapping"][phase_i] = start_lane
            lane_phase_info_dict[intersection['id']]["phase_roadLink_mapping"][phase_i] = lane_pair
            phase_i += 1
    return lane_phase_info_dict

if __name__ == "__main__":
    lane_phase_info = parse_roadnet("manhattan/manhattan.json")
    print(len(lane_phase_info)) # 3763
    count_phase = defaultdict(int)
    for inter in lane_phase_info.keys():
        count_phase[len(lane_phase_info[inter]['phase'])]+=1
    print(count_phase) # defaultdict(<class 'int'>, {1: 1421, 2: 1459, 4: 6, 9: 182, 8: 678, 10: 1, 3: 16})

@WaterFountain-Jack
Copy link

WaterFountain-Jack commented Mar 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants