コード例 #1
0
    def __init__(self,
                 veh_id,
                 sumo_cf_params,
                 k_d=1,
                 k_v=1,
                 k_c=1,
                 d_des=1,
                 v_des=8,
                 time_delay=0.0,
                 noise=0,
                 fail_safe=None):
        """Instantiates a Bilateral car-following model controller. Looks ahead
        and behind.

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        sumo_cf_params: SumoCarFollowingParams
            see parent class
        k_d: float, optional
            gain on distances to lead/following cars (default: 1)
        k_v: float, optional
            gain on vehicle velocity differences (default: 1)
        k_c: float, optional
            gain on difference from desired velocity to current (default: 1)
        d_des: float, optional
            desired headway (default: 1)
        v_des: float, optional
            desired velocity (default: 8)
        time_delay: float, optional
            time delay (default: 0.5)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        fail_safe: str, optional
            type of flow-imposed failsafe the vehicle should posses, defaults
            to no failsafe (None)
        """
        BaseController.__init__(self,
                                veh_id,
                                sumo_cf_params,
                                delay=time_delay,
                                fail_safe=fail_safe,
                                noise=noise)

        self.veh_id = veh_id
        self.k_d = k_d
        self.k_v = k_v
        self.k_c = k_c
        self.d_des = d_des
        self.v_des = v_des
コード例 #2
0
    def __init__(self,
                 veh_id,
                 sumo_cf_params,
                 alpha=1,
                 beta=1,
                 h_st=2,
                 h_go=15,
                 v_max=30,
                 time_delay=0,
                 noise=0,
                 fail_safe=None):
        """Instantiates an Optimal Vehicle Model controller.

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        sumo_cf_params: SumoCarFollowingParams
            see parent class
        alpha: float, optional
            gain on desired velocity to current velocity difference
            (default: 0.6)
        beta: float, optional
            gain on lead car velocity and self velocity difference
            (default: 0.9)
        h_st: float, optional
            headway for stopping (default: 5)
        h_go: float, optional
            headway for full speed (default: 35)
        v_max: float, optional
            max velocity (default: 30)
        time_delay: float, optional
            time delay (default: 0.5)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        fail_safe: str, optional
            type of flow-imposed failsafe the vehicle should posses, defaults
            to no failsafe (None)
        """
        BaseController.__init__(self,
                                veh_id,
                                sumo_cf_params,
                                delay=time_delay,
                                fail_safe=fail_safe,
                                noise=noise)
        self.veh_id = veh_id
        self.v_max = v_max
        self.alpha = alpha
        self.beta = beta
        self.h_st = h_st
        self.h_go = h_go
コード例 #3
0
    def __init__(self,
                 veh_id,
                 v_max=30,
                 accel_max=15,
                 decel_max=-5,
                 adaptation=0.65,
                 h_st=5,
                 tau=0.5,
                 dt=0.1,
                 noise=0):
        """
        Instantiates a Linear OVM controller

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        v_max: float, optional
            max velocity (default: 30)
        accel_max: float, optional
            max acceleration (default: 15)
        decel_max: float, optional
            max deceleration (default: -5)
        adaptation: float
            adaptation constant (default: 0.65)
        h_st: float, optional
            headway for stopping (default: 5)
        tau: float, optional
            time delay (default: 0.5)
        dt: float, optional
            timestep (default: 0.1)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        """
        controller_params = {
            "delay": tau / dt,
            "max_deaccel": decel_max,
            "noise": noise
        }
        BaseController.__init__(self, veh_id, controller_params)
        self.accel_queue = collections.deque()
        self.decel_max = decel_max
        self.acc_max = accel_max
        self.veh_id = veh_id
        # 4.8*1.85 for case I, 3.8*1.85 for case II, per Nakayama
        self.v_max = v_max
        # TAU in Traffic Flow Dynamics textbook
        self.adaptation = adaptation
        self.h_st = h_st
        self.delay_time = tau
        self.dt = dt
コード例 #4
0
    def __init__(self,
                 veh_id,
                 v0=30,
                 T=1,
                 a=1,
                 b=1.5,
                 delta=4,
                 s0=2,
                 time_delay=0.0,
                 dt=0.1,
                 noise=0,
                 fail_safe=None,
                 sumo_cf_params=None):
        """Instantiates an Intelligent Driver Model (IDM) controller

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        sumo_cf_params: SumoCarFollowingParams
            see parent class
        v0: float, optional
            desirable velocity, in m/s (default: 30)
        T: float, optional
            safe time headway, in s (default: 1)
        b: float, optional
            comfortable deceleration, in m/s2 (default: 1.5)
        delta: float, optional
            acceleration exponent (default: 4)
        s0: float, optional
            linear jam distance, in m (default: 2)
        dt: float, optional
            timestep, in s (default: 0.1)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        fail_safe: str, optional
            type of flow-imposed failsafe the vehicle should posses, defaults
            to no failsafe (None)
        """
        BaseController.__init__(self, veh_id, sumo_cf_params,
                                delay=time_delay, fail_safe=fail_safe,
                                noise=noise)
        self.v0 = v0
        self.T = T
        self.a = a
        self.b = b
        self.delta = delta
        self.s0 = s0
        self.dt = dt
コード例 #5
0
ファイル: rlcontroller.py プロジェクト: zzjsjspig/flow
    def __init__(self, veh_id, sumo_cf_params, time_delay=0, fail_safe=None):
        """Instantiates an RL Controller.

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        fail_safe: str, optional
            type of flow-imposed failsafe the vehicle should posses, defaults
            to no failsafe (None)
        """
        BaseController.__init__(self,
                                veh_id,
                                sumo_cf_params,
                                delay=time_delay,
                                fail_safe=fail_safe)
コード例 #6
0
    def __init__(self, veh_id, alpha=1, beta=1, h_st=2, h_go=15, v_max=30,
                 accel_max=15, decel_max=-5, tau=0.5, dt=0.1, noise=0):
        """
        Instantiates an Optimal Vehicle Model controller.

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        alpha: float, optional
            gain on desired velocity to current velocity difference
            (default: 0.6)
        beta: float, optional
            gain on lead car velocity and self velocity difference
            (default: 0.9)
        h_st: float, optional
            headway for stopping (default: 5)
        h_go: float, optional
            headway for full speed (default: 35)
        v_max: float, optional
            max velocity (default: 30)
        accel_max: float, optional
            max acceleration (default: 15)
        decel_max: float, optional
            max deceleration (default: -5)
        tau: float, optional
            time delay (default: 0.5)
        dt: float, optional
            timestep (default: 0.1)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        """
        controller_params = {"delay": tau/dt, "max_deaccel": decel_max,
                             "noise": noise}
        BaseController.__init__(self, veh_id, controller_params)
        self.accel_queue = collections.deque()
        self.decel_max = decel_max
        self.accel_max = accel_max
        self.veh_id = veh_id
        self.v_max = v_max
        self.alpha = alpha
        self.beta = beta
        self.h_st = h_st
        self.h_go = h_go
        self.tau = tau
        self.dt = dt
コード例 #7
0
    def __init__(self,
                 veh_id,
                 car_following_params,
                 v_des=13.336,
                 Penetration_rate=0.05,
                 danger_edges=None,
                 control_length=None,
                 no_control_edges=None):
        """Instantiate FollowerStopper."""
        BaseController.__init__(self,
                                veh_id,
                                car_following_params,
                                delay=1.0,
                                fail_safe='safe_velocity')

        # desired speed of the vehicle
        #    self.v_des = v_des
        #    self.entry_headway = solve TRAFFIC_FLOW
        #    self.TRAFFIC_FLOW = solve TRAFFIC_FLOW
        #Design parameters
        self.d0 = 2.5
        self.a = 0.2
        self.b = 0.001
        self.v_max = 30
        #self.TRAFFIC_INFLOW_speed = 11
        #       if env == None:
        self.v_des = v_des
        self.v_fast = 24
        #       else:
        #          self.v_des = min(self.a+self.b*env.time_counter * env.sim_step,1)*v_des
        #        self.v_des = min(self.a+self.b*env.time_counter * env.sim_step,1)*TRAFFIC_INFLOW_speed
        #        self.v_des = min(self.a+self.b*env.time_counter * env.sim_step,1)*v_max*((np.tanh(env.entry_headway/env.h_st-2)+np.tanh(2))/(1+np.tanh(2)))
        self.k = 1.0
        self.dx_1_0 = 4.5
        self.dx_2_0 = 5.25
        self.dx_3_0 = 6.0
        self.d_1 = 1.5
        self.d_2 = 1.0
        self.d_3 = 0.5
        self.d = 1
        self.ref_time = 0
        # maximum achievable acceleration by the vehicle
        self.max_accel = car_following_params.controller_params['accel']

        # other parameters
        self.danger_edges = danger_edges if danger_edges else {}
コード例 #8
0
ファイル: die_controller.py プロジェクト: africamonkey/flow
 def __init__(self,
              veh_id,
              a=1,
              time_delay=0.0,
              dt=0.1,
              noise=0,
              fail_safe=None,
              car_following_params=None):
     """Instantiate an IDM controller."""
     BaseController.__init__(self,
                             veh_id,
                             car_following_params,
                             delay=time_delay,
                             fail_safe=fail_safe,
                             noise=noise)
     self.a = a
     self.dt = dt
     self.go_action = False
コード例 #9
0
    def __init__(self, veh_id, max_deacc=15, tau=0, dt=0.1):
        """
        Instantiates an RL Controller. Vehicles with this controller are
        provided with actions by rllab, and perform their actions accordingly.

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        acc_max: float, optional
            max acceleration (default: 15)
        tau: float, optional
            time delay (default: 0)
        dt: float, optional
            timestep (default: 0.1)
        """
        controller_params = {"delay": tau / dt, "max_deaccel": max_deacc}
        BaseController.__init__(self, veh_id, controller_params)
コード例 #10
0
    def __init__(self,
                 veh_id,
                 sumo_cf_params,
                 v_max=30,
                 adaptation=0.65,
                 h_st=5,
                 time_delay=0.0,
                 noise=0,
                 fail_safe=None):
        """Instantiates a Linear OVM controller

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        sumo_cf_params: SumoCarFollowingParams
            see parent class
        v_max: float, optional
            max velocity (default: 30)
        adaptation: float
            adaptation constant (default: 0.65)
        h_st: float, optional
            headway for stopping (default: 5)
        time_delay: float, optional
            time delay (default: 0.5)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        fail_safe: str, optional
            type of flow-imposed failsafe the vehicle should posses, defaults
            to no failsafe (None)
        """
        BaseController.__init__(self,
                                veh_id,
                                sumo_cf_params,
                                delay=time_delay,
                                fail_safe=fail_safe,
                                noise=noise)
        self.veh_id = veh_id
        # 4.8*1.85 for case I, 3.8*1.85 for case II, per Nakayama
        self.v_max = v_max
        # TAU in Traffic Flow Dynamics textbook
        self.adaptation = adaptation
        self.h_st = h_st
コード例 #11
0
    def __init__(self, veh_id, v0=30, T=1, a=1, b=1.5, delta=4, s0=2, s1=0,
                 decel_max=-5, dt=0.1, noise=0):
        """
        Instantiates an Intelligent Driver Model (IDM) controller

        Attributes
        ----------
        veh_id: str
            Vehicle ID for SUMO identification
        v0: float, optional
            desirable velocity, in m/s (default: 30)
        T: float, optional
            safe time headway, in s (default: 1)
        a: float, optional
            maximum acceleration, in m/s2 (default: 1)
        b: float, optional
            comfortable deceleration, in m/s2 (default: 1.5)
        delta: float, optional
            acceleration exponent (default: 4)
        s0: float, optional
            linear jam distance, in m (default: 2)
        s1: float, optional
            nonlinear jam distance, in m (default: 0)
        decel_max: float, optional
            max deceleration, in m/s2 (default: -5)
        dt: float, optional
            timestep, in s (default: 0.1)
        noise: float, optional
            std dev of normal perturbation to the acceleration (default: 0)
        """
        tau = T  # the time delay is taken to be the safe time headway
        controller_params = {"delay": tau / dt, "max_deaccel": decel_max,
                             "noise": noise}
        BaseController.__init__(self, veh_id, controller_params)
        self.v0 = v0
        self.T = T
        self.a = a
        self.b = b
        self.delta = delta
        self.s0 = s0
        self.s1 = s1
        self.max_deaccel = decel_max
        self.dt = dt
コード例 #12
0
 def __init__(self, veh_id, k_d=1, k_v=1, k_c=1, d_des=1, v_des=8,
              accel_max=15, decel_max=-5, tau=0.5, dt=0.1, noise=0):
     """
     Instantiates a Bilateral car-following model controller. Looks ahead
     and behind.
     
     Attributes
     ----------
     veh_id: str
         Vehicle ID for SUMO identification
     k_d: float, optional
         gain on distances to lead/following cars (default: 1)
     k_v: float, optional
         gain on vehicle velocity differences (default: 1)
     k_c: float, optional
         gain on difference from desired velocity to current (default: 1)
     d_des: float, optional
         desired headway (default: 1)
     v_des: float, optional
         desired velocity (default: 8)
     accel_max: float, optional
         max acceleration (default: 15)
     decel_max: float
         max deceleration (default: -5)
     tau: float, optional
         time delay (default: 0.5)
     dt: float, optional
         timestep (default: 0.1)
     noise: float, optional
         std dev of normal perturbation to the acceleration (default: 0)
     """
     controller_params = {"delay": tau / dt, "max_deaccel": decel_max,
                          "noise": noise}
     BaseController.__init__(self, veh_id, controller_params)
     self.veh_id = veh_id
     self.k_d = k_d
     self.k_v = k_v
     self.k_c = k_c
     self.d_des = d_des
     self.v_des = v_des
     self.accel_max = accel_max
     self.accel_queue = collections.deque()
コード例 #13
0
    def __init__(self, veh_id, car_following_params):
        """Instantiate PISaturation."""
        BaseController.__init__(self, veh_id, car_following_params, delay=1.0)

        # maximum achievable acceleration by the vehicle
        self.max_accel = car_following_params.controller_params['accel']

        # history used to determine AV desired velocity
        self.v_history = []

        # other parameters
        self.gamma = 2
        self.g_l = 7
        self.g_u = 30
        self.v_catch = 1

        # values that are updated by using their old information
        self.alpha = 0
        self.beta = 1 - 0.5 * self.alpha
        self.U = 0
        self.v_target = 0
        self.v_cmd = 0
コード例 #14
0
 def __init__(self,
              veh_id,
              car_following_params,
              v_max=30,
              adaptation=0.65,
              h_st=5,
              time_delay=0.0,
              noise=0,
              fail_safe=None):
     """Instantiate a Linear OVM controller."""
     BaseController.__init__(self,
                             veh_id,
                             car_following_params,
                             delay=time_delay,
                             fail_safe=fail_safe,
                             noise=noise)
     self.veh_id = veh_id
     # 4.8*1.85 for case I, 3.8*1.85 for case II, per Nakayama
     self.v_max = v_max
     # TAU in Traffic Flow Dynamics textbook
     self.adaptation = adaptation
     self.h_st = h_st
コード例 #15
0
ファイル: velocity_controllers.py プロジェクト: bdtmnk/flow
    def __init__(self,
                 veh_id,
                 car_following_params,
                 v_des=15,
                 danger_edges=None):
        """Inspired by Dan Work's... work:

        Dissipation of stop-and-go waves via control of autonomous vehicles:
        Field experiments https://arxiv.org/abs/1705.01693

        Parameters
        ----------
        veh_id: str
            unique vehicle identifier
        v_des: float, optional
            desired speed of the vehicles (m/s)
        """
        BaseController.__init__(self,
                                veh_id,
                                car_following_params,
                                delay=1.0,
                                fail_safe='safe_velocity')

        # desired speed of the vehicle
        self.v_des = v_des

        # maximum achievable acceleration by the vehicle
        self.max_accel = car_following_params.controller_params['accel']

        # other parameters
        self.dx_1_0 = 4.5
        self.dx_2_0 = 5.25
        self.dx_3_0 = 6.0
        self.d_1 = 1.5
        self.d_2 = 1.0
        self.d_3 = 0.5
        self.danger_edges = danger_edges if danger_edges else {}
コード例 #16
0
    def __init__(self,
                 veh_id,
                 car_following_params,
                 v_des=15,
                 danger_edges=None):
        """Instantiate FollowerStopper."""
        BaseController.__init__(
            self, veh_id, car_following_params, delay=1.0,
            fail_safe='safe_velocity')

        # desired speed of the vehicle
        self.v_des = v_des

        # maximum achievable acceleration by the vehicle
        self.max_accel = car_following_params.controller_params['accel']

        # other parameters
        self.dx_1_0 = 4.5
        self.dx_2_0 = 5.25
        self.dx_3_0 = 6.0
        self.d_1 = 1.5
        self.d_2 = 1.0
        self.d_3 = 0.5
        self.danger_edges = danger_edges if danger_edges else {}
コード例 #17
0
 def __init__(self,
              veh_id,
              car_following_params,
              alpha=1,
              beta=1,
              h_st=2,
              h_go=15,
              v_max=30,
              time_delay=0,
              noise=0,
              fail_safe=None):
     """Instantiate an Optimal Vehicle Model controller."""
     BaseController.__init__(self,
                             veh_id,
                             car_following_params,
                             delay=time_delay,
                             fail_safe=fail_safe,
                             noise=noise)
     self.veh_id = veh_id
     self.v_max = v_max
     self.alpha = alpha
     self.beta = beta
     self.h_st = h_st
     self.h_go = h_go
コード例 #18
0
 def __init__(self, veh_id, car_following_params):
     """Instantiate an RL Controller."""
     BaseController.__init__(self, veh_id, car_following_params)