Пример #1
0
def test_offramp_network():
    n = 5
    t = 15
    fw = CTMFreeway.standard(n)
    ic = InitialConditions.blank(n)
    bc = BoundaryConditions.blank(n, t)
    ic.mainline[:] = 2.0
    bc.demand[:, :4] = .3
    bc.split_ratios[:, :] = .8
    scen = Scenario(fw, ic, bc)
    IpOptSolver(n_iters=100).solve(CTMAdjoint(scen), scen.no_control().flatten())
Пример #2
0
def test_offramp_network():
    beta_op.beta = 200.0
    beta_op.factor = 1.000
    beta_op.beta_admm_factor = 1.000
    beta_op.inner_iters = 15
    beta = 10.0
    n = 5
    t = 15
    fw = CTMFreeway.standard(n)
    ic = InitialConditions.blank(n)
    bc = BoundaryConditions.blank(n, t)
    ic.mainline[:] = 2.0
    bc.demand[:, :4] = 0.3
    bc.split_ratios[:, :] = 0.8
    scen = Scenario(fw, ic, bc)
    print scen.ttt(scen.simulate())
    sln = CtmAdjointAdmm.from_full_scenario(scen, 2, beta=beta, n_iters=400).solve().density_summary()
Пример #3
0
def test_smoother():
    beta_op.beta = 20.0
    beta_op.factor = 1.000
    beta_op.beta_admm_factor = 1.000
    beta_op.inner_iters = 30
    beta = 1.0
    n = 6
    t = 10
    fw = CTMFreeway.standard(n)
    ic = InitialConditions.blank(n)
    bc = BoundaryConditions.blank(n, t)
    ic.mainline[:] = 1.0
    ic.queue[0] = 0.5
    ic.queue[[3]] = 0.5
    bc.demand[0, :] = 0.5
    bc.demand[[1, 4], :2] = 0.3
    scen = Scenario(fw, ic, bc)
    print scen.ttt(scen.simulate())
    scen.simulate().plot()
    # IpOptSolver(n_iters=100).solve(CTMAdjoint(scen), scen.no_control().flatten())
    # u_star = AcceleratedGradient(n_iters=40, beta=50.0, lb=0.0, ub=1.0).solve(CTMAdjoint(scen),
    #                                                                         scen.no_control().transpose().flatten())
    #
    #
    # print scen.ttt(scen.simulate(u_star))
    # scen.simulate(u_star).plot()
    sln = CtmAdjointAdmm.from_full_scenario(scen, 3, beta=beta, n_iters=100).solve()
    u_star = sln.construct_control()
    sln.density_summary()
    print "###########"
    print CTMAdjoint(scen).j(scen.simulate(u_star), u_star)
    print scen.ttt(scen.simulate(u_star))
    u_star = AcceleratedGradient(n_iters=20, beta=20.0, lb=0.0, ub=1.0).solve(
        CTMAdjoint(scen), u_star.transpose().flatten()
    )
    print scen.ttt(scen.simulate(u_star))