Ejemplo n.º 1
0
    def do_epos_planning(cls, tick):
        prepare_epos_input_data_folders()

        cars_to_indexes = {}
        i = 0
        for car_id, car in CarRegistry.cars.iteritems():
            if car.create_epos_output_files_based_on_current_location(
                    tick, str(i)):
                cars_to_indexes[car_id] = i
                i += 1

        number_of_epos_plans = len([
            name for name in os.listdir('datasets/plans')
            if name.endswith("plans")
        ])
        print "Number of EPOS plans: " + str(number_of_epos_plans)

        Knowledge.time_of_last_EPOS_invocation = tick

        cls.change_EPOS_config("conf/epos.properties", "numAgents=",
                               "numAgents=" + str(number_of_epos_plans))
        cls.change_EPOS_config(
            "conf/epos.properties", "planDim=",
            "planDim=" + str(Network.edgesCount() * Knowledge.planning_steps))
        cls.change_EPOS_config("conf/epos.properties", "alpha=",
                               "alpha=" + str(Knowledge.alpha))
        cls.change_EPOS_config("conf/epos.properties", "beta=",
                               "beta=" + str(Knowledge.beta))
        cls.change_EPOS_config(
            "conf/epos.properties", "globalCostFunction=",
            "globalCostFunction=" + str(Knowledge.globalCostFunction))

        cls.run_epos_apply_results(False, cars_to_indexes, tick)
Ejemplo n.º 2
0
def start(processID, parallelMode,useGUI):

    random.seed(Config.random_seed)

    """ main entry point into the application """
    Config.parallelMode = parallelMode
    Config.sumoUseGUI = useGUI

    info('#####################################', Fore.CYAN)
    info('#        Starting TRAPP v0.1        #', Fore.CYAN)
    info('#####################################', Fore.CYAN)

    # Check if sumo is installed and available
    SUMODependency.checkDeps()
    info('# SUMO-Dependency check OK!', Fore.GREEN)

    # Load the sumo map we are using into Python
    Network.loadNetwork()
    info(Fore.GREEN + "# Map loading OK! " + Fore.RESET)
    info(Fore.CYAN + "# Nodes: " + str(Network.nodesCount()) + " / Edges: " + str(Network.edgesCount()) + Fore.RESET)

    # After the network is loaded, we init the router
    CustomRouter.init()
    # Start sumo in the background
    SUMOConnector.start()
    info("\n# SUMO-Application started OK!", Fore.GREEN)
    # Start the simulation
    Simulation.start()
    # Simulation ended, so we shutdown
    info(Fore.RED + '# Shutdown' + Fore.RESET)
    traci.close()
    sys.stdout.flush()
    return None
Ejemplo n.º 3
0
def start(processID, parallelMode, useGUI):
    """ main entry point into the application """
    Config.processID = processID
    Config.parallelMode = parallelMode
    Config.sumoUseGUI = useGUI

    info('#####################################', Fore.CYAN)
    info('#      Starting CrowdNav v0.2       #', Fore.CYAN)
    info('#####################################', Fore.CYAN)
    info('# Configuration:', Fore.YELLOW)
    info('# Kafka-Host   -> ' + Config.kafkaHost, Fore.YELLOW)
    info('# Kafka-Topic1 -> ' + Config.kafkaTopicTrips, Fore.YELLOW)
    info('# Kafka-Topic2 -> ' + Config.kafkaTopicPerformance, Fore.YELLOW)

    # init sending updates to kafka and getting commands from there
    if Config.kafkaUpdates or Config.mqttUpdates:
        RTXForword.connect()
        RTXConnector.connect()

    # Check if sumo is installed and available
    SUMODependency.checkDeps()
    info('# SUMO-Dependency check OK!', Fore.GREEN)

    # Load the sumo map we are using into Python
    Network.loadNetwork()
    info(Fore.GREEN + "# Map loading OK! " + Fore.RESET)
    info(Fore.CYAN + "# Nodes: " + str(Network.nodesCount()) + " / Edges: " +
         str(Network.edgesCount()) + Fore.RESET)

    # After the network is loaded, we init the router
    CustomRouter.init()
    # Start sumo in the background
    SUMOConnector.start()
    info("\n# SUMO-Application started OK!", Fore.GREEN)
    # Start the simulation
    Simulation.start()
    # Simulation ended, so we shutdown
    info(Fore.RED + '# Shutdown' + Fore.RESET)
    traci.close()
    sys.stdout.flush()
    return None
Ejemplo n.º 4
0
    def start(cls):

        Knowledge.planning_period = Config.planning_period
        Knowledge.planning_step_horizon = Config.planning_step_horizon
        Knowledge.planning_steps = Config.planning_steps
        Knowledge.alpha = Config.alpha
        Knowledge.beta = Config.beta
        Knowledge.globalCostFunction = Config.globalCostFunction

        Util.remove_overhead_and_streets_files()
        Util.add_data_folder_if_missing()

        CSVLogger.logEvent("streets", [edge.id for edge in Network.routingEdges])

        Util.prepare_epos_input_data_folders()

        """ start the simulation """
        info("# Start adding initial cars to the simulation", Fore.MAGENTA)
        # apply the configuration from the json file
        cls.applyFileConfig()
        CarRegistry.applyCarCounter()

        if Config.start_with_epos_optimization:
            Knowledge.time_of_last_EPOS_invocation = 0
            CarRegistry.change_EPOS_config("conf/epos.properties", "numAgents=", "numAgents=" + str(Config.totalCarCounter))
            CarRegistry.change_EPOS_config("conf/epos.properties", "planDim=", "planDim=" + str(Network.edgesCount() * Knowledge.planning_steps))
            CarRegistry.change_EPOS_config("conf/epos.properties", "alpha=", "alpha=" + str(Knowledge.alpha))
            CarRegistry.change_EPOS_config("conf/epos.properties", "beta=", "beta=" + str(Knowledge.beta))
            CarRegistry.change_EPOS_config("conf/epos.properties", "globalCostFunction=", "globalCostFunction=" + str(Knowledge.globalCostFunction))

            cars_to_indexes = {}
            for i in range(Config.totalCarCounter):
                cars_to_indexes["car-" + str(i)] = i
            CarRegistry.run_epos_apply_results(True, cars_to_indexes, 0)

        cls.loop()