Indeed saving flows at each iteration has been simple. I also managed (I think) to save and read the paths generated through the assignment. Based on the code for turn volumes, I now run:
def read_paths_from_folder(paths_dir: Path, iteration: int) -> pd.DataFrame:
path_file_regex = re.compile("^o([0-9]+).feather$")
print(path_file_regex)
files = {
int(re.match(path_file_regex, p_file.name).groups()[0]): p_file
for p_file in paths_dir.glob("*.feather")
if re.match(path_file_regex, p_file.name) is not None
}
path_list = []
for origin in files.keys():
o_paths_df = pd.read_feather(paths_dir / f"o{origin}.feather")
o_idx_paths_df = pd.read_feather(paths_dir / f"o{origin}_indexdata.feather")
# looks like the indices dataframe is ffilled for missing destinations
# grab destinations only from first index
path_starts = o_idx_paths_df.reset_index().groupby("data", as_index=False).first().set_index("index")
# looks like indices are offset by 1
path_starts["data"] -= 1
# only keeping destinations with indices > 0
path_starts = path_starts[path_starts["data"] > 0].copy()
# add info to paths df
o_paths_df["origin_idx"] = origin
o_paths_df.loc[path_starts["data"], "destination_idx"] = path_starts.index.values
o_paths_df["destination_idx"] = o_paths_df["destination_idx"].bfill()
path_list.append(o_paths_df)
all_paths = pd.concat(path_list)
all_paths[["network mode", "class_name", "iteration"]] = ["c", "tc_car", iteration]
return all_paths
And I obtain a table with "data, origin_idx, destination_idx, network mode, class_name and iteration". Hoping it is not a nuisance, I have the following questions:
- What does the data column exactly represent? Also, I expected a list of links on each path, is there an additional item I should try to retrieve like o_paths_df["links"]?
- I am trying to obtain the route choice (or more precisely, the volume load on each path) at each iteration. Am I checking in the right place? Or should I try to modify/use other classes?
I hope the many questions are not a nuisance. Hopefully I am almost ready to run the experiments, as the rest of the code is set.
Thank you again :)