Example #1
0
    def update_simulator(self):
        base_config = configurations[self.ui.configuration.currentIndex()][1]
        throughput = self.ui.throughput.value()
        config = configs.througput(base_config, throughput=throughput)

        logger.info("Max Waits: %s",
                    [sp['max_wait'] for sp in config['spawners']])
        logger.info("Min Waits: %s",
                    [sp['min_wait'] for sp in config['spawners']])

        logger.info('Pausing the simulation')
        self.simulator.set_paused(True)
        logger.info('Removing all vehicles')
        self.simulator.remove_all_vehicles()
        logger.info('Resetting the spawners')
        self.simulator.reset_all_spawners()

        logger.info('Configuring the spawners')
        for spawner_conf in config['spawners']:
            self.simulator.configure_spawner(spawner_conf)

        logger.info('Starting the simulation')

        self.simulator.set_paused(False)

        logger.info('Resetting the stats')
        self.simulator.reset_stats()

        self.simulator.clear_queue()
        self.ui.start.setEnabled(True)
        self.ui.stop.setEnabled(True)
Example #2
0
    def update_simulator(self):
        base_config = configurations[self.ui.configuration.currentIndex()][1]
        throughput = self.ui.throughput.value()
        config = configs.througput(base_config, throughput=throughput)

        logger.info("Max Waits: %s", [sp['max_wait'] for sp in config['spawners']])
        logger.info("Min Waits: %s", [sp['min_wait'] for sp in config['spawners']])

        logger.info('Pausing the simulation')
        self.simulator.set_paused(True)
        logger.info('Removing all vehicles')
        self.simulator.remove_all_vehicles()
        logger.info('Resetting the spawners')
        self.simulator.reset_all_spawners()

        logger.info('Configuring the spawners')
        for spawner_conf in config['spawners']:
            self.simulator.configure_spawner(spawner_conf)

        logger.info('Starting the simulation')

        self.simulator.set_paused(False)

        logger.info('Resetting the stats')
        self.simulator.reset_stats()

        self.simulator.clear_queue()
        self.ui.start.setEnabled(True)
        self.ui.stop.setEnabled(True)
Example #3
0
def add_task(config_name, throughput, short):
    config_name = config_name.upper()
    base_config = getattr(configs, config_name)
    config = configs.througput(base_config, throughput=throughput)

    if short:
        config["warmup_time"] = 30
        config["run_time"] = 30

    network.add_task(config)
Example #4
0
def add_task(config_name, throughput, short):
    config_name = config_name.upper()
    base_config = getattr(configs, config_name)
    config = configs.througput(base_config, throughput=throughput)

    if short:
        config['warmup_time'] = 30
        config['run_time'] = 30

    network.add_task(config)
Example #5
0
def add_tasks(config_name, start, end, step, n=1):
    task_configs = []
    config_name = config_name.upper()
    base_config = getattr(configs, config_name)
    for throughput in np.arange(start, end, step):
        config = configs.througput(base_config, throughput=throughput)

        task_configs.append(config)

    task_configs = task_configs * n

    network.add_tasks(task_configs)
Example #6
0
def add_tasks(config_name, start, end, step, n=1):
    task_configs = []
    config_name = config_name.upper()
    base_config = getattr(configs, config_name)
    for throughput in np.arange(start, end, step):
        config = configs.througput(base_config, throughput=throughput)

        task_configs.append(config)

    task_configs = task_configs * n

    network.add_tasks(task_configs)
Example #7
0
def run_locally(existing, config_name, throughput, short):
    config_name = config_name.upper()
    base_config = getattr(configs, config_name)
    config = configs.througput(base_config, throughput=throughput)

    if short:
        config["warmup_time"] = 30
        config["run_time"] = 30

    with Simulator(start=not existing) as simulator:
        logger.info("Max Waits: %s", [sp["max_wait"] for sp in config["spawners"]])
        logger.info("Min Waits: %s", [sp["min_wait"] for sp in config["spawners"]])

        logger.info("Pausing the simulation")
        simulator.set_paused(True)
        logger.info("Removing all vehicles")
        simulator.remove_all_vehicles()
        logger.info("Resetting the spawners")
        simulator.reset_all_spawners()

        logger.info("Configuring the spawners")
        for spawner_conf in config["spawners"]:
            simulator.configure_spawner(spawner_conf)

        logger.info("Starting the recording")

        try:
            os.mkdir("recordings")
        except WindowsError:
            pass
        replayname = time.strftime("recordings/recording_%Y.%m.%d_%H.%M.%S.bin")
        simulator.start_recording(replayname)

        logger.info("Starting the simulation")

        simulator.set_paused(False)

        logger.info("Resetting the stats")
        simulator.reset_stats()

        logger.info("Warming up the simulation")

        time_start = time.time()

        simulator.clear_queue()

        print ""

        while True:
            stats = simulator.receive_stats()
            logger.debug("(Warmup) Got stats: %s", stats)
            if time.time() - time_start < 2.0:
                # Ensure we wait at least 2 seconds, in case of old data
                continue
            if stats["time"] >= config["warmup_time"]:
                break

            print (CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE)
            print "  ".join(["%s: %s" % (key, value) for key, value in stats.items()])

        logger.info("Warmup complete!")

        timeline = []
        log = []

        print ""

        max_time = config["run_time"] + config["warmup_time"]

        last_status = -100.0

        while True:
            stats = simulator.receive_stats()

            timeline.append(stats)
            logger.debug("Got stats: %s", stats)

            for entry in simulator.get_log_entries():
                log.append(entry)
                logger.info("Got log entry")
                logger.debug("Got log entry: %s", entry)

            current_time = stats["time"]

            if current_time >= max_time:
                break

            percent_complete = (current_time / max_time) * 100.0

            print (CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE)
            print ("  ".join(["%s: %s" % (key, value) for key, value in stats.items()]) + " %.1f %%" % percent_complete)

        logger.info("Stopping Recording")

        simulator.stop_recording()

        logger.info("Completed run")

        incidents = timeline[-1]["incidents"] - timeline[0]["incidents"]
        throughputs = [d["throughputs"][1] for d in timeline]
        avg_throughput = sum(throughputs) / len(throughputs)

        logger.info("Avg Throughput: %.2f" % avg_throughput)
        logger.info("Incidents: %d" % incidents)
Example #8
0
def run_locally(existing, config_name, throughput, short):
    config_name = config_name.upper()
    base_config = getattr(configs, config_name)
    config = configs.througput(base_config, throughput=throughput)

    if short:
        config['warmup_time'] = 30
        config['run_time'] = 30

    with Simulator(start=not existing) as simulator:
        logger.info("Max Waits: %s",
                    [sp['max_wait'] for sp in config['spawners']])
        logger.info("Min Waits: %s",
                    [sp['min_wait'] for sp in config['spawners']])

        logger.info('Pausing the simulation')
        simulator.set_paused(True)
        logger.info('Removing all vehicles')
        simulator.remove_all_vehicles()
        logger.info('Resetting the spawners')
        simulator.reset_all_spawners()

        logger.info('Configuring the spawners')
        for spawner_conf in config['spawners']:
            simulator.configure_spawner(spawner_conf)

        logger.info("Starting the recording")

        try:
            os.mkdir('recordings')
        except WindowsError:
            pass
        replayname = time.strftime(
            'recordings/recording_%Y.%m.%d_%H.%M.%S.bin')
        simulator.start_recording(replayname)

        logger.info('Starting the simulation')

        simulator.set_paused(False)

        logger.info('Resetting the stats')
        simulator.reset_stats()

        logger.info('Warming up the simulation')

        time_start = time.time()

        simulator.clear_queue()

        print ''

        while True:
            stats = simulator.receive_stats()
            logger.debug("(Warmup) Got stats: %s", stats)
            if time.time() - time_start < 2.0:
                # Ensure we wait at least 2 seconds, in case of old data
                continue
            if stats['time'] >= config['warmup_time']:
                break

            print(CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE)
            print '  '.join(
                ['%s: %s' % (key, value) for key, value in stats.items()])

        logger.info("Warmup complete!")

        timeline = []
        log = []

        print ''

        max_time = config['run_time'] + config['warmup_time']

        last_status = -100.0

        while True:
            stats = simulator.receive_stats()

            timeline.append(stats)
            logger.debug("Got stats: %s", stats)

            for entry in simulator.get_log_entries():
                log.append(entry)
                logger.info("Got log entry")
                logger.debug("Got log entry: %s", entry)

            current_time = stats['time']

            if current_time >= max_time:
                break

            percent_complete = (current_time / max_time) * 100.0

            print(CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE)
            print(
                '  '.join(
                    ['%s: %s' % (key, value)
                     for key, value in stats.items()]) +
                " %.1f %%" % percent_complete)

        logger.info("Stopping Recording")

        simulator.stop_recording()

        logger.info("Completed run")

        incidents = timeline[-1]['incidents'] - timeline[0]['incidents']
        throughputs = [d['throughputs'][1] for d in timeline]
        avg_throughput = sum(throughputs) / len(throughputs)

        logger.info("Avg Throughput: %.2f" % avg_throughput)
        logger.info("Incidents: %d" % incidents)