Пример #1
0
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--steps", type=int)
parser.add_argument("-f", "--filename", type=str)
parser.add_argument("-e", "--evaluate", type=bool)
parser.add_argument("--seed", type=int)
args = parser.parse_args()
args.steps = 1000
args.seed = 100
args.filename = 'network_config_agent_0_layers_11_6_1.txt'

print(args.steps, args.seed, args.filename, args.evaluate)

steps = args.steps
seed = args.seed if args.seed else 23
np.random.seed(seed)
random.seed(seed)
m = generate_map(8, 5, 3, 3)

if args.filename:
    agent = SimpleCarAgent.from_file(args.filename)
    w = SimpleCarWorld(5, m, SimplePhysics, SimpleCarAgent, timedelta=0.2)
    if args.evaluate:
        print(w.evaluate_agent(agent, steps))
    else:
        w.set_agents([agent])
        w.run(steps)
else:
    SimpleCarWorld(5, m, SimplePhysics, SimpleCarAgent,
                   timedelta=0.2).run(steps)
import numpy as np
import random

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-s", "--steps", type=int)
parser.add_argument("-f", "--filename", type=str)
parser.add_argument("-e", "--evaluate", type=bool)
parser.add_argument("--seed", type=int)
args = parser.parse_args()

print(args.steps, args.seed, args.filename, args.evaluate)

steps = args.steps
seed = args.seed if args.seed else 23
np.random.seed(seed)
random.seed(seed)
m = generate_map(8, 5, 3, 3)

if args.filename:
    agent = SimpleCarAgent.from_file(args.filename)
    w = SimpleCarWorld(1, m, SimplePhysics, SimpleCarAgent, timedelta=0.2)
    if args.evaluate:
        print(w.evaluate_agent(agent, steps))
    else:
        w.set_agents([agent])
        w.run(steps)
else:
    SimpleCarWorld(1, m, SimplePhysics, SimpleCarAgent, timedelta=0.2).run(steps)
Пример #3
0
# etas = [0.1]
# train_everies = [100]
# epochs_ns = [50]

if args.evaluate and args.filename:
    w = SimpleCarWorld(1,
                       m,
                       SimplePhysics,
                       SimpleCarAgent, [9, 9],
                       100,
                       20,
                       0.02,
                       timedelta=0.2)
    agent = SimpleCarAgent.from_file(args.filename, [9, 9])
    w.set_agents([agent])
    print(w.evaluate_agent(agent, 1200))

else:
    for e in etas:
        for t in train_everies:
            for ep in epochs_ns:
                for ls in hidden_layers:
                    for seed in seeds:
                        print(
                            "E: {0}; train: {1}; Epochs: {2}; Layers: {3}: Seed: {4}"
                            .format(e, t, ep, ls, seed))
                        np.random.seed(seed)
                        random.seed(seed)
                        m = generate_map(8, 5, 3, 3)
                        w = SimpleCarWorld(1,
                                           m,
Пример #4
0
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--steps", type=int)
parser.add_argument("-f", "--filename", type=str)
parser.add_argument("-e", "--evaluate", type=bool)
parser.add_argument("--seed", type=int)
args = parser.parse_args()

print(args.steps, args.seed, args.filename, args.evaluate)

steps = args.steps
seed = args.seed if args.seed else 23
np.random.seed(seed)
random.seed(seed)
m = generate_map(20, 2, 1, 1)
radii = np.random.normal(loc=2.5, scale=0.2, size=8)
angles = get_partition(8, -np.pi, np.pi)
o = generate_obstacles(8, radii, angles, 0)

if args.filename:
    agent = SimpleCarAgent.from_file(args.filename)
    w = SimpleCarWorld(1, m, o, radii, angles, SimplePhysics, SimpleCarAgent, timedelta=0.2)
    if args.evaluate:
        with open('results.txt', 'a') as inf:
            circles, collisions = w.evaluate_agent(agent, SimplePhysics, steps, timedelta=0.2)
            inf.write('seed: {} circles: {} collisions: {} \n'.format(seed, circles, collisions))
    else:
        w.set_agents([agent])
        w.run(SimplePhysics, steps, timedelta=0.2)
else:
    SimpleCarWorld(1, m, o, radii, angles, SimplePhysics, SimpleCarAgent, timedelta=0.2).run(SimplePhysics, steps, timedelta=0.2)
Пример #5
0
import random

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-s", "--steps", type=int)
parser.add_argument("-f", "--filename", type=str)
parser.add_argument("-e", "--evaluate", type=bool)
parser.add_argument("--seed", type=int)
args = parser.parse_args()

print(args.steps, args.seed, args.filename, args.evaluate)

steps = args.steps
seed = args.seed if args.seed else 23
np.random.seed(seed)
random.seed(seed)
m = generate_map(8, 5, 3, 3)

if args.filename:
    agent = SimpleCarAgent.from_file(args.filename)
    w = SimpleCarWorld(1, m, SimplePhysics, SimpleCarAgent, timedelta=0.2)
    if args.evaluate:
        with open('results.txt', 'a') as inf:
            inf.write('seed: ' + str(seed) + ' circles: ' + str(w.evaluate_agent(agent, steps)) + '\n')
    else:
        w.set_agents([agent])
        w.run(steps)
else:
    SimpleCarWorld(1, m, SimplePhysics, SimpleCarAgent, timedelta=0.2).run(steps)