old_contents: #!/usr/bin/env python
  
  import sys
  import time
  from pymmspa import *
  
  source_list = ["59529822", "59525660", "59524276", "59523770", "59522730",
                 "59522320", "59521579", "59521043", "59520663", "59519758",
                 "59519243", "59518864", "59517890", "59516900", "59509174",
                 "59505072", "59503373", "568143481", "540165540", "813389942",
                 "729211573", "655810285", "59533211", "59526235", "59525530",
                 "59523807", "59523129", "59522463", "59521966", "59521294",
                 "59520905", "59519810", "59519332", "59519142", "59518007",
                 "59517610", "59509422", "59505327", "59504778", "568143762",
                 "540175071", "817093120", "749091723", "674407202", "655769154",
                 "59523916", "59523680", "59522594", "59522016", "59519381"]
  mode_list = ['underground', 'foot']
  
  
  def do_benchmarking(algorithm):
      print "Loading multimodal transportation networks in Munich..."
      t1 = time.time()
      parse("/Users/user/Research/phd-work/data/UM/")
      t2 = time.time()
      print "done! Time consumed: " + str(t2 - t1) + " seconds"
      print "Start benchmarking multimodal path calculation for algorithm " + algorithm.upper() + " ..."
      print "Test for randomly selected " + str(len(source_list)) + " sources"
      print "Input mode list are: " + str(mode_list)
      t1 = time.time()
      for s in source_list:
          if algorithm.upper() == 'MMTQ':
              mm_twoq(mode_list, s)
          elif algorithm.upper() == 'MMD':
              mm_dijkstra(mode_list, s)
          elif algorithm.upper() == 'MMBF':
              mm_bellmanford(mode_list, s)
      t2 = time.time()
      print "done! Average calculation time: " + str((t2 - t1) / len(source_list)) + " seconds"
      dispose()
  
  if __name__ == "__main__":
      do_benchmarking(sys.argv[1])
  
new_contents: #!/usr/bin/env python
  
  import sys
  import time
  from termcolor import colored
  from pymmspa4pg import *
  
  source_list = []
  target_list = []
  
  def load_routing_options(
          sources_file_path,
          targets_file_path,
          options_file_path):
      with open(sources_file_path) as sources_file:
          source_list = [source.strip() for source in sources_file.readlines()]
      with open(targets_file_path) as targets_file:
          target_list = [target.strip() for target in targets_file.readlines()]
      options = read_routing_options(options_file_path)
  
  def read_routing_options(options_file_path):
      return options_file_path
  
  def do_benchmarking(sources, targets, options):
      print "Connecting to database... ",
      if connect_db("dbname = 'mmrp_munich' user = 'liulu' password = 'workhard'") != 0:
          print colored("failed!", "red")
          exit()
      print colored("done!", "green")
      print "Preparing routing plan... ",
      create_routing_plan(1, 1)
      set_mode(0, 1900)
      set_public_transit_mode(0, 1003)
      set_cost_factor("speed")
      print colored("done!", "green")
      print "Loading multimodal transportation networks in Munich... ",
      t1 = time.time()
      if parse() != 0:
          print colored("failed!", "red")
          exit()
      t2 = time.time()
      print colored("done!", "green")
      print "Time consumed: " + str(t2 - t1) + " seconds"
      print "Test for randomly selected " + str(len(sources)) + " source vertices"
      print "Routing plan: by underground trains"
      print "Start benchmarking multimodal path calculation by MultimodalTwoQ... ",
      t1 = time.time()
      for s in sources:
          multimodal_twoq(long(s))
      t2 = time.time()
      print colored("done!", "green")
      print "Average calculation time: " + str((t2 - t1) / len(sources)) + " seconds"
      print "Post processing... ",
      dispose()
      print colored("done!", "green")
      print "Disconnect database... ",
      disconnect_db()
      print colored("done!", "green")
  
  if __name__ == "__main__":
      with open(sys.argv[1]) as f_sources:
          source_list = [source.strip() for source in f_sources.readlines()]
      with open(sys.argv[2]) as f_targets:
          target_list = [target.strip() for target in f_targets.readlines()]
      #options = read_routing_options(options_file_path)
      options = ""
      do_benchmarking(source_list, target_list, options)
  
subject: modify the demo benchmark program according to the new interfaces