Exemple #1
0
def run():
    """
    :return:
    """
    conf = parser.parse_args()
    conf.world_step_size = 0.004

    fname = conf.output_directory + "/benchmark.csv"
    exists = os.path.exists(fname)
    if exists:
        f = open(fname, 'ab', buffering=1)
    else:
        f = open(fname, 'wb', buffering=1)

    output = csv.writer(f, delimiter=',')

    if not exists:
        output.writerow([
            'run', 'population_size', 'step_size', 'sim_time', 'real_time',
            'factor'
        ])

    world = yield From(OnlineEvoManager.create(conf))
    yield From(wait_for(world.pause(False)))

    population_sizes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
    sim_time = 5
    runs = 20

    for n in population_sizes:
        for i in range(runs):
            trees, bboxes = yield From(world.generate_population(n))
            for tree, bbox in zip(trees, bboxes):
                res = yield From(world.birth(tree, bbox, None))
                yield From(res)
                yield From(trollius.sleep(0.05))

            while world.last_time is None:
                yield From(trollius.sleep(0.1))

            sim_before = world.last_time
            before = time.time()

            while float(world.last_time - sim_before) < sim_time:
                yield From(trollius.sleep(0.1))

            sim_diff = float(world.last_time - sim_before)
            diff = time.time() - before

            output.writerow(
                (i, n, conf.world_step_size, sim_diff, diff, sim_diff / diff))

            yield From(wait_for(world.delete_all_robots()))
            yield From(trollius.sleep(0.3))

    f.close()
Exemple #2
0
def run():
    """
    :return:
    """
    conf = parser.parse_args()
    conf.world_step_size = 0.004

    fname = conf.output_directory+"/benchmark.csv"
    exists = os.path.exists(fname)
    if exists:
        f = open(fname, 'ab', buffering=1)
    else:
        f = open(fname, 'wb', buffering=1)

    output = csv.writer(f, delimiter=',')

    if not exists:
        output.writerow(['run', 'population_size', 'step_size',
                         'sim_time', 'real_time', 'factor'])

    world = yield From(OnlineEvoManager.create(conf))
    yield From(wait_for(world.pause(False)))

    population_sizes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
    sim_time = 5
    runs = 20

    for n in population_sizes:
        for i in range(runs):
            trees, bboxes = yield From(world.generate_population(n))
            for tree, bbox in zip(trees, bboxes):
                res = yield From(world.birth(tree, bbox, None))
                yield From(res)
                yield From(trollius.sleep(0.05))

            while world.last_time is None:
                yield From(trollius.sleep(0.1))

            sim_before = world.last_time
            before = time.time()

            while float(world.last_time - sim_before) < sim_time:
                yield From(trollius.sleep(0.1))

            sim_diff = float(world.last_time - sim_before)
            diff = time.time() - before

            output.writerow((i, n, conf.world_step_size, sim_diff,
                             diff, sim_diff / diff))

            yield From(wait_for(world.delete_all_robots()))
            yield From(trollius.sleep(0.3))

    f.close()
Exemple #3
0
import os
import sys
from revolve.util import Supervisor
from online_evolve import parser

here = os.path.dirname(os.path.abspath(__file__))
tol_path = os.path.abspath(os.path.join(here, '..', '..'))
rv_path = os.path.abspath(os.path.join(tol_path, '..', 'revolve'))

args = parser.parse_args()

os.environ['GAZEBO_PLUGIN_PATH'] = os.path.join(tol_path, 'build')
os.environ['GAZEBO_MODEL_PATH'] = os.path.join(tol_path, 'tools', 'models')

supervisor = Supervisor(manager_cmd=[sys.executable, "online_evolve.py"],
                        analyzer_cmd=os.path.join(rv_path, 'tools', 'analyzer',
                                                  'run-analyzer'),
                        world_file=os.path.join(here, 'online-evolve.world'),
                        output_directory=args.output_directory,
                        manager_args=sys.argv[1:],
                        restore_directory=args.restore_directory)

supervisor.launch()
Exemple #4
0
    def write_stderr(self, data):
        """
        :param data:
        :return:
        """
        if 'ODE Message 3' in data:
            self.ode_errors += 1
        elif data.strip():
            sys.stderr.write(data)

        if self.ode_errors >= 100:
            self.ode_errors = 0
            sys.stderr.write('ODE Message 3 (100)\n')

manager_cmd = [sys.executable, "online_evolve.py"]
analyzer_cmd = os.path.join(rv_path, 'tools', 'analyzer', 'run-analyzer')
world_file = os.path.join(here, 'online-evolve.world')

if __name__ == '__main__':
    args = parser.parse_args()
    supervisor = OnlineEvolutionSupervisor(
        manager_cmd=manager_cmd,
        analyzer_cmd=analyzer_cmd,
        world_file=world_file,
        output_directory=args.output_directory,
        manager_args=sys.argv[1:],
        restore_directory=args.restore_directory
    )
    supervisor.launch()