Changeset 1291 for framspy


Ignore:
Timestamp:
01/15/24 05:46:02 (12 months ago)
Author:
Maciej Komosinski
Message:

Cosmetic

Location:
framspy/evolalg
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • framspy/evolalg/base/experiment_islands_model_abc.py

    r1190 r1291  
    2828        sorted_individuals = sorted(
    2929            pool_of_all_individuals, key=lambda x: x.rawfitness)
    30         print(f"Best indiviudal for new islands:")
     30        print("Best individual for new islands:")
    3131        for i in range(self.number_of_populations):
    3232            shift = i*self.popsize
  • framspy/evolalg/frams_base/experiment_frams.py

    r1190 r1291  
    77
    88class ExperimentFrams(ExperimentABC):
    9     def __init__(self, hof_size, popsize, frams_lib, optimization_criteria, genformat, save_only_best=True, constraints={}) -> None:
     9    def __init__(self, hof_size, popsize, frams_lib, optimization_criteria, genformat, save_only_best, constraints={}) -> None:
    1010        ExperimentABC.__init__(self, hof_size=hof_size, popsize=popsize, save_only_best=save_only_best)
    1111        self.optimization_criteria = optimization_criteria
  • framspy/evolalg/tests/test_diferent_settings.py

    r1205 r1291  
    11import argparse
    22import sys
     3import numpy as np
    34
    45from FramsticksLib import FramsticksLib
     
    910from ..numerical_example.numerical_islands_example import ExperimentNumericalIslands
    1011
    11 
    1212from ..utils import ensureDir
    1313
     14
     15GENERATIONS = 10
     16
    1417SETTINGS_TO_TEST_NUMERIC = {
    1518    'hof_size': [0, 10],
     
    1922    'pxov': [0.2],
    2023    'tournament': [5],
    21     'initialgenotype':[[100, 100, 100, 100], [-100,-100]]
     24    'initialgenotype':[np.array([100, 100, 100, 100]), [-100,-100]]
    2225}
    2326
     
    3134    'migration_interval': [1,5],
    3235    'number_of_populations':[1,5],
    33     'initialgenotype':[[100, 100, 100, 100], [-100,-100]]
     36    'initialgenotype':[np.array([100, 100, 100, 100]), [-100,-100]]
    3437}
    3538
     
    8184
    8285    experiment.evolve(hof_savefile=None,
    83                       generations=2,
     86                      generations=GENERATIONS,
    8487                      initialgenotype=params['initialgenotype'],
    8588                      pmut=params['pmut'],
     
    99102
    100103    experiment.evolve(hof_savefile=None,
    101                       generations=2,
     104                      generations=GENERATIONS,
    102105                      initialgenotype=params['initialgenotype'],
    103106                      pmut=params['pmut'],
     
    117120                  }
    118121
    119     print('Best individuals:')
    120122    experiment = ExperimentFramsNiching(frams_lib=framsLib,
    121123                                        optimization_criteria=opt_criteria,
     
    128130                                        popsize=params['popsize'],
    129131                                        archive_size=params['archive'],
    130                                         save_only_best=True)
    131 
    132     experiment.evolve(hof_savefile=None,
    133                       generations=2,
     132                                        save_only_best=True,
     133                                        knn_niching=5,
     134                                        knn_nslc=5)
     135
     136    experiment.evolve(hof_savefile=None,
     137                      generations=GENERATIONS,
    134138                      initialgenotype=params['initialgenotype'],
    135139                      pmut=params['pmut'],
     
    149153                  }
    150154
    151     print('Best individuals:')
    152155    experiment = ExperimentFramsIslands(frams_lib=framsLib,
    153156                                        optimization_criteria=opt_criteria,
     
    161164
    162165    experiment.evolve(hof_savefile=None,
    163                       generations=2,
     166                      generations=GENERATIONS,
    164167                      initialgenotype=params['initialgenotype'],
    165168                      pmut=params['pmut'],
     
    201204        run_exp(params)
    202205        return [1, None]
    203     except Exception as e:
    204         return [0, f"Experiment {run_exp.__name__} with params:{params} failied with the stack:{e}"]
     206    except Exception as ex:
     207        return [0, f"Experiment {run_exp.__name__} with params: {params} failed with the stack: {ex}"]
    205208
    206209
Note: See TracChangeset for help on using the changeset viewer.