Пример #1
0
def exp_4():
  net = StateConstrainedNetwork.load('../networks/fpnet_with_demands.json')
  net.objective = lambda: 0
  l_9 = net.link_by_name('9')
  l_3 = net.link_by_name('3')
  l_8 = net.link_by_name('8')
  for link in net.get_links():
    if link in [l_9, l_3, l_8]:
      link.set_cong_state(link.CongState.CONG)
    else:
      link.set_cong_state(link.CongState.FF)
  net.get_program().cr_solve()
  net.realize()
  print net.total_travel_time()
  net.dump('../networks/exps/exp4/net_cong.json')

  net = StateConstrainedNetwork.load('../networks/exps/exp4/net_cong.json')
  net.get_program().cr_solve()
  net.realize()
  print net.total_travel_time()

  net = StateConstrainedComplacentNetwork.load('../networks/exps/exp4/net_cong.json')
  net.scale = 1.1
  net.get_program().cr_solve()
  net.realize()
  print net.total_travel_time()

  net = StateConstrainedComplacentNetwork.load('../networks/exps/exp4/net_cong.json')
  net.scale = 1000.0
  net.get_program().cr_solve()
  net.realize()
  print net.total_travel_time()

  net = StateConstrainedComplacentNetwork.load('../networks/exps/exp4/net_cong.json')
  net.scale = 10.0
  net.get_program().cr_solve()
  net.realize()
  print net.total_travel_time()
def exp_3_info():
  net = StateConstrainedComplacentNetwork.load('../networks/exps/exp3/net_demand.json')
  print 'ttt previous', net.total_travel_time()
  net.get_program().cr_solve()
  net.realize()
  print 'ttt after complacence optimize', net.total_travel_time()
  for route in net.all_routes():
    print 'route', route
    print 'heur tt', net.route_tt_heuristic(route).value
    print 'actual tt', route.travel_time()
  net = StateConstrainedNetwork.load('../networks/exps/exp3/net_demand.json')
  net.get_program().cr_solve()
  net.realize()
  print 'ttt after non-comp optimize', net.total_travel_time()
Пример #3
0
def exp_3_info():
  net = StateConstrainedComplacentNetwork.load('../networks/exps/exp3/net_demand.json')
  for cls in net.__class__.__mro__:
    print cls
  print 'ttt previous', net.total_travel_time()
  net.get_program().cr_print()
  net.get_program().cr_solve(quiet=False)
  for link in net.get_links():
    print link
    print link.v_dens.value
    print link.l
  net.realize()
  print 'ttt after complacence optimize', net.total_travel_time()
  for route in net.all_routes():
    print 'route', route
    print 'heur tt', net.route_tt_heuristic(route).value
    print 'actual tt', net.route_travel_time(route)
  net = StateConstrainedNetwork.load('../networks/exps/exp3/net_demand.json')
  net.get_program().cr_solve()
  net.realize()
  print 'ttt after non-comp optimize', net.total_travel_time()
Пример #4
0
def exp_3_setup():
  net = StateConstrainedComplacentNetwork()
  l = 1; v = 1; w = 1; q_max = 1; rho_max = 2; r = 1;

  fd = FundamentalDiagram.triangular(
    v=v,q_max=q_max,rho_max=rho_max
  )

  l_rho = 1.372281323
  r_rho = 3 - l_rho

  source = StateConstrainedLink(
    fd=fd,
    name='source',
    cong_state=StateConstrainedLink.CongState.ANY,
    l=l,
    flow=r,
    density=fd.rho_ff(r)
  )
  left = StateConstrainedLink(
    fd=fd,
    name='left',
    cong_state=StateConstrainedLink.CongState.CONG,
    l=2*l,
    flow=fd.flow_cong(l_rho),
    density=l_rho
  )
  right = StateConstrainedLink(
    fd=fd,
    name='right',
    cong_state=StateConstrainedLink.CongState.CONG,
    l=l,
    flow=fd.flow_cong(r_rho),
    density=r_rho
  )
  sink = StateConstrainedLink(
    fd=fd,
    name='sink',
    cong_state=StateConstrainedLink.CongState.ANY,
    l=l,
    flow=r,
    density=fd.rho_ff(r)
  )
  js = [
    Junction([source],[left,right]),
    Junction([left,right],[sink]),
  ]
  [net.add_junction(junction) for junction in js]
  net.dump('../networks/exps/exp3/net.json')
  left_demand = RouteDemand(
    route=net.route_by_names(['source','left','sink']),
    flow=.2
  )
  od_demand = ODDemand(
    source=source,
    sink=sink,
    flow=.8
  )
  net.demands.append(left_demand)
  net.demands.append(od_demand)
  net.dump('../networks/exps/exp3/net_demand.json')
Пример #5
0
def exp_2():
  """
  starting to figure out stateconstrained things
  """
  net = StateConstrainedComplacentNetwork.load('../../networks/exps/exp2/lf_rc.json')
  net.get_program().cr_print()