Ignore:
Timestamp:
02/01/23 22:58:25 (22 months ago)
Author:
Maciej Komosinski
Message:

Cosmetic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/FramsticksEvolution.py

    r1191 r1195  
    2121
    2222
    23 def frams_evaluate(frams_cli, individual):
     23def frams_evaluate(frams_lib, individual):
    2424        BAD_FITNESS = [-1] * len(OPTIMIZATION_CRITERIA)  # fitness of -1 is intended to discourage further propagation of this genotype via selection ("this genotype is very poor")
    2525        genotype = individual[0]  # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.
    26         data = frams_cli.evaluate([genotype])
     26        data = frams_lib.evaluate([genotype])
    2727        # print("Evaluated '%s'" % genotype, 'evaluation is:', data)
    2828        valid = True
     
    4747
    4848
    49 def frams_crossover(frams_cli, individual1, individual2):
     49def frams_crossover(frams_lib, individual1, individual2):
    5050        geno1 = individual1[0]  # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.
    5151        geno2 = individual2[0]  # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.
    52         individual1[0] = frams_cli.crossOver(geno1, geno2)
    53         individual2[0] = frams_cli.crossOver(geno1, geno2)
     52        individual1[0] = frams_lib.crossOver(geno1, geno2)
     53        individual2[0] = frams_lib.crossOver(geno1, geno2)
    5454        return individual1, individual2
    5555
    5656
    57 def frams_mutate(frams_cli, individual):
    58         individual[0] = frams_cli.mutate([individual[0]])[0]  # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.
     57def frams_mutate(frams_lib, individual):
     58        individual[0] = frams_lib.mutate([individual[0]])[0]  # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.
    5959        return individual,
    6060
    6161
    62 def frams_getsimplest(frams_cli, genetic_format, initial_genotype):
    63         return initial_genotype if initial_genotype is not None else frams_cli.getSimplest(genetic_format)
     62def frams_getsimplest(frams_lib, genetic_format, initial_genotype):
     63        return initial_genotype if initial_genotype is not None else frams_lib.getSimplest(genetic_format)
    6464
    6565
    66 def prepareToolbox(frams_cli, OPTIMIZATION_CRITERIA, tournament_size, genetic_format, initial_genotype):
     66def prepareToolbox(frams_lib, OPTIMIZATION_CRITERIA, tournament_size, genetic_format, initial_genotype):
    6767        creator.create("FitnessMax", base.Fitness, weights=[1.0] * len(OPTIMIZATION_CRITERIA))
    6868        creator.create("Individual", list, fitness=creator.FitnessMax)  # would be nice to have "str" instead of unnecessary "list of str"
    6969
    7070        toolbox = base.Toolbox()
    71         toolbox.register("attr_simplest_genotype", frams_getsimplest, frams_cli, genetic_format, initial_genotype)  # "Attribute generator"
     71        toolbox.register("attr_simplest_genotype", frams_getsimplest, frams_lib, genetic_format, initial_genotype)  # "Attribute generator"
    7272        # (failed) struggle to have an individual which is a simple str, not a list of str
    7373        # toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_frams)
     
    7878        toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_simplest_genotype, 1)
    7979        toolbox.register("population", tools.initRepeat, list, toolbox.individual)
    80         toolbox.register("evaluate", frams_evaluate, frams_cli)
    81         toolbox.register("mate", frams_crossover, frams_cli)
    82         toolbox.register("mutate", frams_mutate, frams_cli)
     80        toolbox.register("evaluate", frams_evaluate, frams_lib)
     81        toolbox.register("mate", frams_crossover, frams_lib)
     82        toolbox.register("mutate", frams_mutate, frams_lib)
    8383        if len(OPTIMIZATION_CRITERIA) <= 1:
    8484                toolbox.register("select", tools.selTournament, tournsize=tournament_size)
     
    9090def parseArguments():
    9191        parser = argparse.ArgumentParser(description='Run this program with "python -u %s" if you want to disable buffering of its output.' % sys.argv[0])
    92         parser.add_argument('-path', type=ensureDir, required=True, help='Path to Framsticks CLI without trailing slash.')
    93         parser.add_argument('-lib', required=False, help='Library name. If not given, "frams-objects.dll" or "frams-objects.so" is assumed depending on the platform.')
     92        parser.add_argument('-path', type=ensureDir, required=True, help='Path to Framsticks library without trailing slash.')
     93        parser.add_argument('-lib', required=False, help='Library name. If not given, "frams-objects.dll" (or .so or .dylib) is assumed depending on the platform.')
    9494        parser.add_argument('-sim', required=False, default="eval-allcriteria.sim", help="The name of the .sim file with settings for evaluation, mutation, crossover, and similarity estimation. If not given, \"eval-allcriteria.sim\" is assumed by default. Must be compatible with the \"standard-eval\" expdef. If you want to provide more files, separate them with a semicolon ';'.")
    9595
Note: See TracChangeset for help on using the changeset viewer.