Changeset 1292 for framspy/evolalg
- Timestamp:
- 02/21/24 16:50:31 (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/evolalg/tests/test_diferent_settings.py
r1291 r1292 22 22 'pxov': [0.2], 23 23 'tournament': [5], 24 'initialgenotype':[np.array([100, 100, 100, 100]), [-100,-100]]24 'initialgenotype':[np.array([100, 100, 100, 100]), np.array([-100,-100])] 25 25 } 26 26 … … 34 34 'migration_interval': [1,5], 35 35 'number_of_populations':[1,5], 36 'initialgenotype':[np.array([100, 100, 100, 100]), [-100,-100]]36 'initialgenotype':[np.array([100, 100, 100, 100]), np.array([-100,-100])] 37 37 } 38 38 … … 201 201 202 202 def cover_to_test(params, run_exp): 203 try: 204 run_exp(params) 205 return [1, None] 206 except Exception as ex: 207 return [0, f"Experiment {run_exp.__name__} with params: {params} failed with the stack: {ex}"] 203 run_exp(params) 204 return 1 208 205 209 206 210 207 def run_tests(): 211 result = [] 208 results = [] 209 212 210 print("TESTING NUMERICAL") 213 211 params_sets = get_params_sets(SETTINGS_TO_TEST_NUMERIC) 214 212 print(f"Starting executing {len(params_sets)} experiments") 215 result .extend([cover_to_test(params,test_run_experiment_numerical) for params in params_sets])213 results.extend([cover_to_test(params, test_run_experiment_numerical) for params in params_sets]) 216 214 217 215 print("TESTING NUMERICAL ISLANDS") 218 216 params_sets = get_params_sets(SETTINGS_TO_TEST_NUMERIC_ISLAND) 219 217 print(f"Starting executing {len(params_sets)} experiments") 220 result .extend([cover_to_test(params,test_run_experiment_numerical_islands) for params in params_sets])218 results.extend([cover_to_test(params,test_run_experiment_numerical_islands) for params in params_sets]) 221 219 222 220 print("TESTING FRAMS NICHING") 223 221 params_sets = get_params_sets(SETTINGS_TO_TEST_FRAMS_NICHING) 224 222 print(f"Starting executing {len(params_sets)} experiments") 225 result .extend([cover_to_test(params, test_run_experiment_frams_niching) for params in params_sets])223 results.extend([cover_to_test(params, test_run_experiment_frams_niching) for params in params_sets]) 226 224 227 225 print("TESTING FRAMS ISLANDS") 228 226 params_sets = get_params_sets(SETTINGS_TO_TEST_FRAMS_ISLANDS) 229 227 print(f"Starting executing {len(params_sets)} experiments") 230 result.extend([cover_to_test(params,test_run_experiment_frams_island) for params in params_sets]) 231 232 Successful = sum([1 for r in result if r[0] == 1]) 233 Failed = sum([1 for r in result if r[0] == 0]) 234 print(f"{Successful} out of {len(result)} passed") 235 if Successful < Failed: 236 print("Experiments that failed :{Failed}") 237 [print(r[1]) for r in result if r[1]] 228 results.extend([cover_to_test(params,test_run_experiment_frams_island) for params in params_sets]) 229 230 print(f"Passed tests: {sum(results)} / {len(results)}") 238 231 239 232
Note: See TracChangeset
for help on using the changeset viewer.