def test_loading_columns(): network = pg.read_network() print('\nstart loading columns\n') st = time() pg.load_columns(network) print('processing time of loading columns :{0: .2f}'.format(time() - st) + 's') print('\nstart column generation\n') st = time() iter_num = 0 column_update_num = 10 pg.perform_network_assignment(1, iter_num, column_update_num, network) print('processing time of column generation:{0: .2f}'.format(time() - st) + 's' f' for {iter_num} assignment iterations and ' f'{column_update_num} iterations in column generation') pg.output_columns(network) pg.output_link_performance(network) print('\npath finding results can be found in agent.csv')
def test_find_shortest_path_for_agents(): network = pg.read_network() st = time() network.find_path_for_agents() print('\nprocessing time of finding shortest paths for all agents:{0: .2f}' .format(time() - st) + 's') agent_id = 300 print('\norigin node id of agent is ' + str(network.get_agent_orig_node_id(agent_id))) print('destination node id of agent is ' + str(network.get_agent_dest_node_id(agent_id))) print('shortest path (node id) of agent is ' + str(network.get_agent_node_path(agent_id))) print('shortest path (link id) of agent is ' + str(network.get_agent_link_path(agent_id))) agent_id = 1000 print('\norigin node id of agent is ' + str(network.get_agent_orig_node_id(agent_id))) print('destination node id of agent is ' + str(network.get_agent_dest_node_id(agent_id))) print('shortest path (node id) of agent is ' + str(network.get_agent_node_path(agent_id))) print('shortest path (link id) of agent is ' + str(network.get_agent_link_path(agent_id)))
def test_find_shortest_path_for_agents(): network = pg.read_network() st = time() network.find_path_for_agents() print('\nprocessing time of finding shortest paths for all agents: ' f'{time()-st:.2f} s') 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)}') # output unique agent paths to a csv file # if you do not want to include geometry info in the output file, # you can do pg.output_agent_paths(network, False) pg.output_agent_paths(network)
def test_loading_columns(): network = pg.read_network() print('\nstart loading columns\n') st = time() pg.load_columns(network) print(f'processing time of loading columns: {time()-st:.2f} s') print('\nstart column generation') st = time() column_gen_num = 0 column_update_num = 10 # pg.perform_network_assignment(assignment_mode=1, column_gen_num, # column_update_num, network) # has been deprecated starting from v0.7.2, and will be removed in later. pg.perform_column_generation(column_gen_num, column_update_num, network) print(f'processing time of column generation: {time()-st:.2f} s' f' for {column_gen_num} iterations in column generation and ' f'{column_update_num} iterations in column update') pg.output_columns(network) pg.output_link_performance(network)
def test_find_shortest_path(): load_demand = False network = pg.read_network(load_demand) print('\nshortest path (node id) from node 1 to node 2 is ' + network.find_shortest_path(1, 2)) print('\nshortest path (link id) from node 1 to node 2 is ' + network.find_shortest_path(1, 2, 'link'))
def test_accessibility(): network = pg.read_network() print('\nstart accessibility evaluation\n') st = time() pg.evaluate_accessiblity(network) print('complete accessibility evaluation.\n') print('processing time of accessibility evaluation:{0: .2f}'.format( time() - st) + 's') print('accessibility matrices can be found in accessibility.csv ' 'and accessibility_aggregated.csv')
def test_find_shortest_path(): network = pg.read_network(load_demand=False) print('\nshortest path (node id) from node 1 to node 2, ' + network.find_shortest_path(1, 2)) print('\nshortest path (link id) from node 1 to node 2, ' + network.find_shortest_path(1, 2, seq_type='link')) # retrieve the shortest path under a specific mode (which must be defined # in settings.yaml) print('\nshortest path (node id) from node 1 to node 2, ' + network.find_shortest_path(1, 2, mode='w')) print('\nshortest path (link id) from node 1 to node 2, ' + network.find_shortest_path(1, 2, mode='w', seq_type='link'))
def test_column_generation_py(): network = pg.read_network() print('\nstart column generation\n') st = time() iter_num = 20 column_update_num = 20 pg.perform_network_assignment(1, iter_num, column_update_num, network) print(f'processing time of column generation: {time()-st:.2f} s' f' for {iter_num} assignment iterations and ' f'{column_update_num} iterations in column generation') # 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)
def test_accessibility(): load_demand = False network = pg.read_network(load_demand) print('\nstart accessibility evaluation\n') st = time() pg.evaluate_accessibility(network) print('complete accessibility evaluation.\n') print(f'processing time of accessibility evaluation: {time()-st:.2f} s') # get accessible nodes and links starting from node 1 with a 5-minitue # time window for the default mode auto (i.e., 'p') network.get_accessible_nodes(1, 5) network.get_accessible_links(1, 5) # get accessible nodes and links starting from node 1 with a 15-minitue # time window for mode walk (i.e., 'w') network.get_accessible_nodes(1, 15, 'w') network.get_accessible_links(1, 15, 'w')
def test_column_generation_py(): network = pg.read_network() print('\nstart column generation\n') st = time() column_gen_num = 10 column_update_num = 10 # pg.perform_network_assignment(assignment_mode=1, assignment_num, # column_update_num, network) # has been deprecated starting from v0.7.2, and will be removed later. pg.perform_column_generation(column_gen_num, column_update_num, network) print(f'processing time of column generation: {time()-st:.2f} s' f' for {column_gen_num} iterations in column generation and ' f'{column_update_num} iterations in column update') # 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)
def test_loading_columns(): network = pg.read_network() print('\nstart loading columns\n') st = time() pg.load_columns(network) print(f'processing time of loading columns: {time()-st:.2f} s') print('\nstart column generation\n') st = time() iter_num = 0 column_update_num = 10 pg.perform_network_assignment(1, iter_num, column_update_num, network) print(f'processing time of column generation: {time()-st:.2f} s' f' for {iter_num} assignment iterations and ' f'{column_update_num} iterations in column generation') pg.output_columns(network) pg.output_link_performance(network)
import path4gmns as pg if __name__ == "__main__": network = pg.read_network() print('the shortest path from node 1 to node 2 is ' + str(pg.find_shortest_path(network, 1, 2))) pg.find_path_for_agents(network) agent = network.agent_list[0] print('the shortest path (node sequence) of agent 0 is ' + str(agent.path_node_seq_no_list)) print('the shortest path (link sequence) of agent 0 is ' + str(agent.path_link_seq_no_list))