예제 #1
0
 def tt_graph():
   global tt_graph_
   if not tt_graph_:
     if not os.path.exists(tt_graph_fname):
       tic("creating empty tt graph", experiment_name)
       tt_graph_ = createTravelTimeGraph(hmm_graph(), radius=2e-4)
       tt_graph_.checkInvariants()
       save_ttg_structure(tt_graph_, experiment_name=experiment_name)
     else:
       tic("reading tt graph from %s"%tt_graph_fname, experiment_name)
       tt_graph_ = pickle.load(open(tt_graph_fname,'r'))
   return tt_graph_
예제 #2
0
  traj_conv_one_mode = createTrajectoryConversion(graph_type=graph_type,
                                            process='mixture_auto',
                                            params=traj_conv_param,
                                            network=net,
                                            max_nb_mixture=1)

  #  mode_counts = dict([(link_id,1) for link_id in net.keys()])
  if graph_type == 'simple':
    hmm_graph = model.createHMMGraphFromNetwork(net, mode_counts=traj_conv.modeCounts())
    hmm_graph_one_mode = model.createHMMGraphFromNetwork(net, mode_counts=traj_conv_one_mode.modeCounts())
    # hmm_graph = model.createHMMGraphFromNetwork(net, mode_counts=mode_counts)
  else:
    # Complex model not implemented
    assert False

  tt_graph = createTravelTimeGraph(hmm_graph, radius=2e-4)
  tt_graph.checkInvariants()

  tt_graph_one_mode = createTravelTimeGraph(hmm_graph_one_mode, radius=2e-4)
  tt_graph_one_mode.checkInvariants()


  gmrf = emptyValues(tt_graph)
  gmrf_one_mode = emptyValues(tt_graph)

  # Checkpoint: save the structures

  save_ttg_structure(tt_graph, experiment_name=experiment_name)
  # The TTG structure is required when loading the GMRF (and the GMRF estimators)
  # Make sure they are saved in all the directories
  save_ttg_structure(tt_graph_one_mode, experiment_name='{0}_one_mode'.format(experiment_name))
def createFillTTGraph(hmm_graph, traj_observations):
  tt_graph = createTravelTimeGraph(hmm_graph, 1e-3)
  fillTTGraph(tt_graph, traj_observations)
  return tt_graph