Changeset 1148 for framspy


Ignore:
Timestamp:
08/10/21 00:48:18 (3 years ago)
Author:
Maciej Komosinski
Message:

Added exception when popsize is not a multiple of 4 (required by deap.tools.selTournamentDCD())

Location:
framspy/evolalg
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • framspy/evolalg/examples/multicriteria.py

    r1147 r1148  
    168168def create_experiment():
    169169    parsed_args = parseArguments()
    170     frams_lib = FramsticksLib(parsed_args.path, parsed_args.lib,
    171                               parsed_args.sim)
     170    frams_lib = FramsticksLib(parsed_args.path, parsed_args.lib, parsed_args.sim)
    172171
    173172    opt_dissim = []
     
    303302    print("Running experiment with", sys.argv)
    304303    parsed_args = parseArguments()
     304   
     305    if parsed_args.popsize % 4 != 0:
     306        raise ValueError("popsize must be a multiple of 4 (for example %d)." % (parsed_args.popsize//4*4)) # required by deap.tools.selTournamentDCD()
     307       
    305308    if parsed_args.debug:
    306309        logging.basicConfig(level=logging.DEBUG)
     
    308311    if parsed_args.checkpoint_path is not None and os.path.exists(parsed_args.checkpoint_path):
    309312        experiment = load_experiment(parsed_args.checkpoint_path)
    310         FramsticksLib(parsed_args.path, parsed_args.lib,
    311                       parsed_args.sim)
     313        FramsticksLib(parsed_args.path, parsed_args.lib, parsed_args.sim)
    312314    else:
    313315        experiment = create_experiment()
  • framspy/evolalg/selection/nsga2.py

    r1147 r1148  
    1111        super(NSGA2Selection, self).call(population)
    1212        pop = tools.selNSGA2(population, len(population))
    13         # TODO make count divisible by 4, is this the best way to do it/is it absolutely required? if this is applied, why popsize must still be a multiple of 4?
     13        # make count divisible by 4, required by deap.tools.selTournamentDCD()
    1414        remainder=count % 4
    1515        if remainder > 0:
Note: See TracChangeset for help on using the changeset viewer.