Esempio n. 1
0
def test2():
    # simulation demo
    # set up the scenario
    scenario = Scenario(Mobility())
    scenario.setup_vehicle_pools()

    total_sim_rounds = int(
        np.ceil(scenario.TOTAL_SIM_TIME / scenario.ONEHOP_DELAY))
    input_time_counts = np.zeros((2 * scenario.LANE_NUM_PER_DIRECT, ),
                                 dtype=float)

    for time_flag in range(total_sim_rounds):

        input_time_counts = input_time_counts \
        + np.ones((2*scenario.LANE_NUM_PER_DIRECT,),dtype=float)*scenario.ONEHOP_DELAY

        scenario.update_position()
        scenario.communication()

        for lane_ID in range(scenario.LANE_NUM_PER_DIRECT):
            # right pool
            if input_time_counts[lane_ID] >= scenario.right_arrival_dt[lane_ID]:
                scenario.input_vehicle(1, lane_ID)
                input_time_counts[lane_ID] = 0.0
            if input_time_counts[lane_ID +
                                 2] >= scenario.left_arrival_dt[lane_ID]:
                scenario.input_vehicle(2, lane_ID)
                input_time_counts[lane_ID + 2] = 0.0
Esempio n. 2
0
 
This module builds a simulation demo of VANETs based on epidemic routing.
"""
import numpy as np
import matplotlib.animation as animation
import matplotlib.pyplot as plt

from vehicle import Mobility
from scenario import Scenario

# simulation demo

#------------------------------------------------------------------------------
# set up the scenario
scenario = Scenario(
    Mobility(),
    road_length=10000,  # the length of the road in meter
    two_direction=True,  # bool-type flag indicates the directions
    lane_width=5.0,  # lane width
    lane_num_per_direct=2,  # the number of lanes per direction
    vehicle_length=5.0,  # length of a vehicle in meter
    onehop_delay=10.0 *
    10**(-3),  # the delay in one-hop communication in second
    total_sim_time=60.0,  # total simulation time in second
    scenario_flag="Freeway_Free",
    commR=50.0)
scenario.setup_vehicle_pools()

#------------------------------------------------------------------------------
# set up basic plot
total_sim_rounds = int(np.ceil(scenario.TOTAL_SIM_TIME /
Esempio n. 3
0
def test1():
    mobility = Mobility()
    scenario = Scenario(mobility)
    scenario.setup_vehicle_pools()