Giter VIP home page Giter VIP logo

jdlph / path4gmns Goto Github PK

View Code? Open in Web Editor NEW
53.0 3.0 24.0 8.9 MB

An open-source, cross-platform, lightweight, and fast Python path engine for networks encoded in GMNS.

Home Page: https://path4gmns.readthedocs.io/en/latest/

License: Apache License 2.0

Python 79.43% CMake 0.31% C++ 6.60% C 1.11% Jupyter Notebook 12.56%
path-engine dtalite shortest-paths traffic-assignment column-generation dynamic-traffic-assignment gradient-projection

path4gmns's People

Contributors

fangtang999 avatar gaotianze avatar jdlph avatar orietrans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

path4gmns's Issues

A suggestion about assertion statement

Hi, I was learning Path4GMNS/path4gmns/colgen.py/def perform_column_generation.
I saw you used the assertion statement like this.
image

The full version of the assertion statement is shown as follows:
image

Actually, you can add the optional message to let users know what’s happening if they meet an AssertionError. Just take the path4gmns code from the screenshot as an example:
123

Thank you.

A question about DemandPeriod class

My question:

In classes.py of Path4GMNS, there are three member variables for DemandPeriod class. However, the method "get_file_name" returns a member variable "file", which is also inconsistent with settings.yml. Could you further explain the function and intention of this method? Many thanks!

The code for defining DemandPeriod class in classes.py file

image

Screenshot of settings.yml file

image

Issue in perform Path-Based UE Traffic Assignment

I can only use the function load_demand() to load demand instead of the function read_network(load_demand = True) shown in the tutorial.

network = pg.read_network()
pg.read_zones(network)
pg.load_demand(network)

column_gen_num = 20
column_update_num = 10

# path-based UE only
pg.perform_column_generation(column_gen_num, column_update_num, network)

# if you do not want to include geometry info in the output file,
# use pg.output_columns(network, False)
pg.output_columns(network)
pg.output_link_performance(network)

image

network = pg.read_network(load_demand=True)

column_gen_num = 20
column_update_num = 10

# path-based UE only
pg.perform_column_generation(column_gen_num, column_update_num, network)

# if you do not want to include geometry info in the output file,
# use pg.output_columns(network, False)
pg.output_columns(network)
pg.output_link_performance(network)

image

zone.csv
node.csv
link.csv
demand.csv

A typo in colgen.py

Hi, there is a typo. It should be "column_update_num" as shown in the red rectangle. Thank you.
image

Issue for Find Shortest Paths for All Individual Agents

By using this legacy way to find paths for agents and conduct traffic assignments (read_network(load_demand=True) ), we still get an exception stating, "NO VALID OD VOLUME!! DOUBLE CHECK YOUR demand.csv".

Source code:

network = pg.read_network(load_demand=True)
network.find_path_for_agents()

agent_id = 300
print('\norigin node id of agent is '
      f'{network.get_agent_orig_node_id(agent_id)}')
print('destination node id of agent is '
      f'{network.get_agent_dest_node_id(agent_id)}')
print('shortest path (node id) of agent, '
      f'{network.get_agent_node_path(agent_id)}')
print('shortest path (link id) of agent, '
      f'{network.get_agent_link_path(agent_id)}')

agent_id = 1000
print('\norigin node id of agent is '
      f'{network.get_agent_orig_node_id(agent_id)}')
print('destination node id of agent is '
      f'{network.get_agent_dest_node_id(agent_id)}')
print('shortest path (node id) of agent, '
      f'{network.get_agent_node_path(agent_id)}')
print('shortest path (link id) of agent, '
      [f'{network.get_agent_link_path(agent_id)}')]([demand.csv](https://github.com/jdlph/Path4GMNS/files/9688167/demand.csv))
pg.output_agent_paths(network)

Error:

Please provide settings.yml next time!
Engine will set up one demand period and one agent type using default values for you, which might NOT reflect your case!

read node.csv
the number of nodes is 357
read link.csv
the number of links is 646
read demand.csv
the number of agents is 0
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
[<ipython-input-15-e9b68bc81fc7>](https://localhost:8080/#) in <module>
----> 1 network = pg.read_network(load_demand=True)
      2 network.find_path_for_agents()
      3 
      4 agent_id = 300
      5 print('\norigin node id of agent is '

1 frames
[/usr/local/lib/python3.7/dist-packages/path4gmns/utils.py](https://localhost:8080/#) in read_demand(input_dir, file, agent_type_id, demand_period_id, zones, column_pool, check_connectivity)
    576 
    577         if total_agents == 0:
--> 578             raise Exception('NO VALID OD VOLUME!! DOUBLE CHECK YOUR demand.csv')
    579 
    580 

Exception: NO VALID OD VOLUME!! DOUBLE CHECK YOUR demand.csv

Problem with travel time

I ran the code and I filled length and speed columns in link.csv, but in the link_performance.csv file I get the travel_time exactly same as length. How can I address this issue?

testing "Perform Path-Based UE Traffic Assignment using the Python Column-Generation Module"

error:

path4gmns, version 0.8.5
read node.csv
the number of nodes is 357
the number of zones is 0
read link.csv
the number of links is 646
current iteration number in column generation: 0
Traceback (most recent call last):
  File "C:\Users\Yuanzheng Edison Lei\PycharmProjects\testGMNS\main.py", line 8, in <module>
    pg.perform_column_generation(column_gen_num, column_update_num, network)
  File "C:\Users\Yuanzheng Edison Lei\PycharmProjects\testGMNS\venv\lib\site-packages\path4gmns\colgen.py", line 337, in perform_column_generation
    _update_link_travel_time_and_cost(links, dps, i)
  File "C:\Users\Yuanzheng Edison Lei\PycharmProjects\testGMNS\venv\lib\site-packages\path4gmns\colgen.py", line 30, in _update_link_travel_time_and_cost
    link.calculate_td_vdf(demand_periods, iter_num)
  File "C:\Users\Yuanzheng Edison Lei\PycharmProjects\testGMNS\venv\lib\site-packages\path4gmns\classes.py", line 175, in calculate_td_vdf
    self.vdfperiods[tau].run_bpr(self.flow_vol_by_period[tau],
  File "C:\Users\Yuanzheng Edison Lei\PycharmProjects\testGMNS\venv\lib\site-packages\path4gmns\classes.py", line 818, in run_bpr
    self.voc = vol / max(SMALL_DIVISOR, self.capacity * reduction_ratio)
TypeError: '>' not supported between instances of 'str' and 'float'

Process finished with exit code 1

primal code:

import path4gmns as pg
from time import time
network = pg.read_network(load_demand=False)
#network = pg.read_network()
column_gen_num = 20
column_update_num = 10
# path-based UE only
pg.perform_column_generation(column_gen_num, column_update_num, network)
# if you do not want to include geometry info in the output file,
# use pg.output_columns(network, False)
pg.output_columns(network)
pg.output_link_performance(network)

data files:
zone.csv
demand.csv
link.csv
node.csv

tutorial.ipynb will not run

I am using the current tutorial.ipynb however when I get to step 3.2 Synthesize Zones and OD Demand Matrix, I get an error back. I have not changed any code or the datafiles it is using--I am just trying to run the original notebook to learn more about the code in general. Thanks for your help!
image

tutorial.ipynb

based on a previous reply, I edited my node.csv and link.csv so that the ids are floats in both and I also used path4gmns==0.9.4. This got me through the first issue and i get the following warning output from 3.1
image
Next I tried two things:

  1. Since I already have a demand.csv and zone.csv from running grid2demand, I ran 3.2 directly from 3.0 with these demand.csv and zone.csv
    zone.csv
    demand.csv
    and I got this error:
image
  1. To see if my issue was stemming from files with grid2demand, I deleted my demand.csv and zone.csv files and ran section 3.2 to create them.
    That created these demand.csv and zone.csv
    zone_from tutorial.csv
    demand_from tutorial.csv
    and yielded this error in the next block of code:
image

I am not sure if these issues stem from downgrading to 0.9.4 or if there is another problem with my data. thanks for your help!

Units of some parameters are unclear

Here are some parameters whose units are unclear:
(1) accessibility in time or distance
(2) distance in km or mile or meter
(3) free_speed in mph or km/h
Hope to indicate the units in the output file or the documentation file.

Removing Links

I was wondering if there was a way of removing links without having to manually edit the csv file? My plan is to remove a link one by one and see the effect this has to the equilibrium time.

Thanks,
Marek

documentation for function: network.find_shortest_path

In the tutorial from version 0.8.7, there is a line of code as follows which is confusing.

print('\nshortest path (link id) from node 1 to node 2, '
      +network.find_shortest_path(1, 2, seq_type='link')) 

The output for the Chicago network will be

shortest path (link id) from node 1 to node 2, distance: 3.06 mi | path: 1;986;989

Its use case has no related statement on how to use arg seq_type. API should discuss the parameters of this very important function.

Travel Time in Agent File

Hello, how is the travel time in the agent.csv file calculated? When I compare the travel time between zones in this file with the EU travel time using the link_performance.csv file they are not consistent.

Some zones are missed

In the network of DC downtown, a zone in middle is lost. Maybe that is caused by no boundary node in that grid. But if there is any POI node, it should be a zone to generate travel demand. Hope the zones could cover all nodes. In other word, each node should be assigned to a unique zone.
)T( 97((OD P_1L)2IALH 8

A question about agent counting

image

In read_demand method, the OD volume is first added by 1 and then be transformed to integral number. Would this operation be excessively overestimate the real amount of OD volume? I suggest it can be first added to the obtain the true though may not be integer value and secondly be transformed to integral number. Thank you.

Is UE in DTA necessary ?

When i use pg.perform_network_assignment_DTALite(mode=2, column_gen_num, column_update_num),the mode is UE + DTA, the UE process is necessary before DTA.
If I have my own agent.csv, can I just call the DNL in PATH4GMNS?
Thank you!

the output result doesn't seem change for different demand files

hey guys thanks for later fixes but i still have some problems with demand.csv and the result not making sense even after reading your guidance in discord server i try to showcase my work as best as i can and thanks for putting the time and maintaining your code.
so i made node.csv and link.csv as the files attached below and made the demand.csv through a python code to make it random everytime it runs the code then put it in a loop to run for 12 times then merged the result into one spreadsheet but the result didn't seem to change even when demand volume and ODs were completely different can i have your opinion on it if i'm doing anything wrong with your code like loading the demand file or is it something wrong with the code i even tried different types of loading the demand.csv file with samples that have been in your library but none seemed to work and gave the "NO VALID OD VOLUME!! DOUBLE CHECK YOUR demand.csv" error (the said error didn't happen in my own main code just for trying to use legacy mode or other ways to load the demand.csv file)
code.zip
link below has the the jupyter notebook code as well
https://github.com/Gyrolyn/vulnerability_management2

Distance for some OD pairs is "N/A"

For the network around ASU, some OD pairs look inaccessible in od_accessibility.csv. The "distance" field and "accessibility" field are "N/A". It's unreasonable.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.