n_iter = 500000
n_gen = 50
TPREFERRED = 26

# Indicates the baseline bout frequency
TRAIN_BOUT_FREQ = 1


def mpath(path):
    return base_path + path[:-1]  # need to remove trailing slash


if __name__ == "__main__":
    # load training data for scaling - dependent on bout frequency
    if TRAIN_BOUT_FREQ == 1:
        std = GradientData.load_standards("gd_training_data.hdf5")
    elif TRAIN_BOUT_FREQ == 0.5:
        std = GradientData.load_standards("gd_05Hz_training_data.hdf5")
    elif TRAIN_BOUT_FREQ == 2:
        std = GradientData.load_standards("gd_2Hz_training_data.hdf5")
    else:
        raise Exception(
            "No training data has been generated for the requested bout frequency"
        )

    # evolve each 512 network unless it has been done before
    for p in paths_512:
        model_path = mpath(p)
        savedir = model_path + '/evolve/'
        if os.path.exists(savedir):
            print(
 mo_type = ""
 while mo_type != "c" and mo_type != "z":
     mo_type = input("Please select either (z)ebrafish or (c) elegans simulation [z/c]:")
     mo_type = mo_type.lower()
 n_steps = 2000000
 TPREFERRED = 25
 root = tk.Tk()
 root.update()
 root.withdraw()
 print("Select model directory")
 model_dir = filedialog.askdirectory(title="Select directory with model checkpoints", initialdir="./model_data/")
 root.update()
 mdata = ModelData(model_dir)
 # load training data for scaling
 if mo_type == "z":
     std = GradientData.load_standards("gd_training_data.hdf5")
 else:
     std = GradientData.load_standards("ce_gd_training_data.hdf5")
 sim_type = ""
 while sim_type != "l" and sim_type != "r":
     sim_type = input("Please select either (l)inear or (r)adial simulation [l/r]:")
 if mo_type == "z":
     mot = MoTypes(False)
 else:
     mot = MoTypes(True)
 gpn_naive = mot.network_model()
 gpn_naive.load(mdata.ModelDefinition, mdata.FirstCheckpoint)
 gpn_trained = mot.network_model()
 gpn_trained.load(mdata.ModelDefinition, mdata.LastCheckpoint)
 if sim_type == "l":
     sim_type = "x"  # so we call run_simulation correctly later