GiulianoCornacchia / Urban-Impact-Navigators

3 stars 1 forks source link

Reproducing results (IGfastest and Milan data) #1

Closed cocomoff closed 2 months ago

cocomoff commented 3 months ago

Thank you for providing an amazing environment for this topic. I reached this repository from your arXiv preprint.

I comment on one minor fix and one question to work your environment on Milan data (= MilanoData.csv.zip).

For src/launcher_sumo_simulation.py.

For 4_launcher_experiments.ipynb.

path_vehicles_mapping = os.path.join(folder_vehicles_mapping, f"dict_set_vehicles_{city}_N{N}.json")

seems to be

path_vehicles_mapping = os.path.join(folder_vehicles_mapping, f"N{N}", f"dict_set_vehicles_{city}_N{N}.json")

to read generated traffic demand data for each N; do you have any comments?

For navigators on 4_launcher_experiments.ipynb and 5_compute_results.ipynb.

Questions: What data are exactly required to output comparisons? (i.e., how to run 5_compute_results.ipynb?)

The below is what I tried:

In 4_launcher_experiments.ipynb:

navigators = ["gmaps"]

In 5_compute_results.ipynb:

list_navigators = ["gmaps"]

To my knowledge, official navigators (e.g., GM, TomTom, etc.) are not included, so a possible approach to generate similar results is to use others. In 3, with w=1 and w=5, we can generate round paths of routed_paths_milan_N5000_IGfastest.rou.xml.gz and routed_paths_milan_N5000_myduaw5.rou.xml.gz in Milan data. The, I imagined that we can compare these results; but now I suffered from understanding 5_compute_results.ipynb, navigators, and rounted_paths.

GiulianoCornacchia commented 3 months ago

Hi @cocomoff,

Thank you for your comment and for bringing these issues to my attention.

Regarding src/launcher_sumo_simulation.py, I have addressed the problem by creating a directory named tmp_folder_add_files to store all auxiliary and additional files. This approach prevents the generation of multiple files in the current working directory.

Additionally, I appreciate your observation about the error in 4_launcher_experiments.ipynb. I have corrected it.

As for the data required to run the 5_compute_results.ipynb notebook, it consists of simulation outputs automatically generated by the 4_launcher_experiments.ipynb notebook. You are correct that official navigation services are not included due to proprietary restrictions. However, in 3_launcher_experiments.ipynb, you can generate a fastest path assignment (IGfastest) by setting w=1, which replicates the functionality of a navigation service prototype. Setting w>1 produces a perturbed fastest path (mydua), followed by vehicles that do not adhere to the navigation service's suggestions. I have updated the code to use IGfastest as the default instead of "gmaps".

Moreover, I have created the notebook 6_create_plots.ipynb, which uses the dictionaries computed in the notebook 5_compute_results.ipynb (or the dictionaries in the results_article folder) to generate plots regarding CO2 emissions and route diversity.

To summarize:

I hope this explanation is clear. If you have further suggestions for improvement, please feel free to fork the repository and submit a pull request or simply share your ideas with me.

Best regards.

cocomoff commented 2 months ago

Glad to hear from @GiulianoCornacchia :)

I've tried the updated versions in my environment. Thank you for your rapid updates. It works much better than the previous version (e.g., the notebook 3).

However, I encountered another issue now.

Some issue on SUMO outputs?:

My environment seems to generate no log.json files after parallel SUMO simulations are finished. I doubt that this gave some issue on utils_result.py called from 5_compute_results.ipynb.

# L.79-81 in utils_result.py
for output_folder in output_folders_list:
    pct, rep = pct_and_rep_from_sim_info(output_folder+"/log.json")

Here, the output folder is like ../data/sim_output/XXXX. My sim_output directories are like below:

image

Do you have any ideas? Can I ask you to share your environments a bit in detail? (i.e. SUMO and Python package versions).

Just for your information, I have attached a screenshot of my directory after running notebooks from 1 to 4. The screenshot explains that 5_compute_results.ipynb has not been finished (no files in dict_results are generated).

image

Sincerely.

GiulianoCornacchia commented 2 months ago

Dear @cocomoff,

I have tested the pipeline on my machine (Python version 3.9.18 and SUMO version 1.19.0), and it appears to work well. Based on the information you provided, it seems there may be an issue in your environment related to converting xml outputs into csv and json files. Could you please confirm that you have placed the files xml2csv.py and xsd.py in the src folder?

The failure of 5_compute_results.ipynb seems to be due to this issue, as it requires the csv and json files for its operation.

I recommend trying to run a single SUMO simulation directly by calling the following command within the src directory (adjusting the parameters as necessary). Please ensure that you are using the newly added launcher_sumo_simulation.py script that I have just updated.

python launcher_sumo_simulation.py -n ../data/road_networks/sumo_road_network_milan.net.xml -r ../data/milan/routed_paths/N5000/routed_paths_milan_N5000_myduaw5.rou.xml.gz -i debug_csv_ -o ../data/sim_output/milan/debug_csv/

This command should fail at the file conversion stage, but analyzing how it fails could help us identify and fix the underlying issue.

Best regards,
Giuliano

cocomoff commented 2 months ago

Thank you for your sincere follow-up.

Before, I was not sure how the simulated data was processed. Running your new launcher_sumo_simulation.py, but now my problem was resolved :)

In my environment, the function convert_xml_to_csv did not work correctly due to the python path (my docker container has python3 instead of python; I set the alias alias python=python3, but it does not work correctly when using Popen through subprocess). After removing old simulation files (i.e., sim_outputs), I finally obtained the .gz files in data/milan/dict_results.

Together with your new notebook (6_create_plots.ipynb) with a modification of the result file, I can reproduce a plot only with FP (= IGfastest). It is almost similar to those in your paper results (= results_milan.json.gz).

Again, thank you for your amazing work, scripts&environments, preprint paper, and your sincere support!

Best regards, Keisuke

GiulianoCornacchia commented 2 months ago

@cocomoff thank you for your kind words and for sharing how you resolved the issue. It is great to hear that your results are closely matching those in the paper.

If you have any more questions or need further support, feel free to reach out. I am happy to help.