Beispiel #1
0
def evaluate_individual(individual):
    """ Wrapper to call Simulation which will evaluate an individual.  

    Args:
        individual: arguments to pass to the simulation

    Returns:
        fitness of an individual
    """

    simulation = Simulation(log_frames=args.log_frames, run_num=args.run_num, eval_time=args.eval_time, dt=.02, n=4)
    return simulation.evaluate_individual_wrap(individual)
args = parser.parse_args()

running = True
eval_time = args.eval_time

output_path = args.output_path
run_num = args.run_num

# Seed only the evolutionary runs.
random.seed(run_num)

if args.debug_runtime:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames,
                            run_num=args.run_num,
                            eval_time=args.eval_time,
                            dt=.02,
                            n=4)

    simulation.debug_validator()
elif args.validator:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames,
                            run_num=args.run_num,
                            eval_time=args.eval_time,
                            dt=.02,
                            n=4)

    # Ensure that the file exists before trying to open to avoid hanging.
    NEAT_file = output_path + "best_individuals/Evo_NEAT_Mus_run_" + str(
        args.run_num) + "_best_gen_" + str(args.gens) + ".dat"
parser.add_argument("--no_periodic",action="store_true",help="Whether we're including a periodic signal or not.")
parser.add_argument("--sym_mus_groups",action="store_true",help="If true, we use half the number of muscle groups enforcing a left/right symmetry in the muscle groups.")
args = parser.parse_args()

running = True
eval_time = args.eval_time 

output_path = args.output_path
run_num = args.run_num

# Seed only the evolutionary runs.
random.seed(run_num)

if args.debug_runtime:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames, run_num=args.run_num, eval_time=args.eval_time, dt=.02, n=4)

    simulation.debug_validator()
elif args.validator:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames, run_num=args.run_num, eval_time=args.eval_time, dt=.02, n=4)

    # Ensure that the file exists before trying to open to avoid hanging.
    NEAT_file = output_path+"best_individuals/Evo_NEAT_Mus_run_"+str(args.run_num)+"_best_gen_"+str(args.gens)+".dat"
    if not os.path.isfile(NEAT_file):
        print("NEAT Genome file doesn't exist! "+NEAT_file)
        exit()

    Mus_Net_File = output_path+"/best_individuals/Evo_NEAT_Mus_run_"+str(run_num)+"_best_mn_gen_"+str(args.gens)+".dat"
    if not os.path.isfile(Mus_Net_File):
        print("Muscle Network file doesn't exist! "+Mus_Net_File)
args = parser.parse_args()

running = True
eval_time = args.eval_time

output_path = args.output_path
run_num = args.run_num

# Seed only the evolutionary runs.
random.seed(run_num)

if args.validator:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames,
                            run_num=args.run_num,
                            eval_time=args.eval_time,
                            dt=.02,
                            n=4,
                            con_type="ind")

    # Ensure that the file exists before trying to open to avoid hanging.
    NEAT_file = output_path + "best_individuals/Evo_NEAT_Mus_run_" + str(
        args.run_num) + "_best_gen_" + str(args.gens) + ".dat"
    if not os.path.isfile(NEAT_file):
        print("NEAT Genome file doesn't exist! " + NEAT_file)
        exit()

    Mus_Net_File = output_path + "/best_individuals/Evo_NEAT_Mus_run_" + str(
        run_num) + "_best_mn_gen_" + str(args.gens) + ".dat"
    if not os.path.isfile(Mus_Net_File):
        print("Muscle Network file doesn't exist! " + Mus_Net_File)
        exit()
Beispiel #5
0
random.seed(run_num)

# Set the fitness function to use in the experiment.
if "Distance" in str(args.fit_func):  #str(args.fit_func)[0] == "D":
    fitness_function = 1
else:
    fitness_function = 2
print("Distance Metric is: " + str(fitness_function) + " Argument is: " +
      str(args.fit_func))
sys.stdout.flush()

if args.debug_runtime:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames,
                            run_num=args.run_num,
                            eval_time=args.eval_time,
                            dt=.02,
                            n=4)

    ann_activations = simulation.validator("")

elif args.validator:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames,
                            run_num=args.run_num,
                            eval_time=args.eval_time,
                            dt=.02,
                            n=4)

    # Ensure that the file exists before trying to open to avoid hanging.
    NEAT_file = output_path + "best_individuals/Evo_NEAT_run_" + str(
parser.add_argument("--config_string",type=str,default="",help="Use a string instead of file for configuration.")
parser.add_argument("--no_periodic",action="store_true",help="Whether we're including a periodic signal or not.")
args = parser.parse_args()

running = True
eval_time = args.eval_time 

output_path = args.output_path
run_num = args.run_num

# Seed only the evolutionary runs.
random.seed(run_num)

if args.debug_runtime:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames, run_num=args.run_num, eval_time=args.eval_time, dt=.02, n=4)

    simulation.debug_validator()
elif args.validator:
    # Initialize the Simulation component
    simulation = Simulation(log_frames=args.log_frames, run_num=args.run_num, eval_time=args.eval_time, dt=.02, n=4)

    # Ensure that the file exists before trying to open to avoid hanging.
    NEAT_file = output_path+"best_individuals/Evo_NEAT_Mus_run_"+str(args.run_num)+"_best_gen_"+str(args.gens)+".dat"
    if not os.path.isfile(NEAT_file):
        print("NEAT Genome file doesn't exist! "+NEAT_file)
        exit()

    simulation.validator(NEAT_file)
else:
    # Ensure that the necessary folders are created for recording data.