Changeset 1289 for framspy/evolalg/base/experiment_niching_abc.py
- Timestamp:
- 01/15/24 05:43:37 (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/evolalg/base/experiment_niching_abc.py
r1272 r1289 24 24 archive_size: int = None 25 25 26 def __init__(self, fit, normalize, popsize, hof_size, save_only_best =True, knn_niching=5, knn_nslc=10, archive_size=0) -> None:26 def __init__(self, fit, normalize, popsize, hof_size, save_only_best, knn_niching, knn_nslc, archive_size) -> None: 27 27 ExperimentABC.__init__(self,popsize=popsize, hof_size=hof_size, save_only_best=save_only_best) 28 28 self.fit = fit … … 51 51 divide_by = np.sum(dissim_matrix) 52 52 else: 53 raise Exception(f"Wrong normalization method,",self.normalize)53 raise ValueError("Wrong normalization method: '%s'" % self.normalize) 54 54 if divide_by != 0: 55 55 return dissim_matrix/divide_by … … 65 65 dissim_list = np.mean(np.partition( 66 66 self.normalize_dissim(dissim_matrix), self.knn_niching)[:, :self.knn_niching], axis=1) 67 68 if Individual.fitness_set_negative_to_zero is False and ("niching" in self.fit or "novelty" in self.fit): 69 raise ValueError("Negative fitness values not tested in combination with niching or novelty. When using these techniques, verify formulas or consider using the flag -fitness_set_negative_to_zero") # once the formulas are verified/improved, the command-line flag and this conditional check can be removed. 67 70 68 71 if "niching" in self.fit: … … 73 76 i.fitness = d 74 77 else: 75 raise Exception("Wrong fit type: ", self.fit, 76 f" choose the correct one or implement a new behavior.") 78 raise ValueError("Unsupported fit type: '%s'. Use the correct type or implement a new behavior." % self.fit) 77 79 population_structures.update_archive(dissim_matrix, population_archive) 78 80
Note: See TracChangeset
for help on using the changeset viewer.