def __init__(self, pop_size=100, sampling=LatinHypercubeSampling(iterations=100, criterion="maxmin"), variant="DE/rand/1/bin", CR=0.5, F=0.3, dither="vector", jitter=False, **kwargs): """ Parameters ---------- pop_size : {pop_size} sampling : {sampling} variant : {{DE/(rand|best)/1/(bin/exp)}} The different variants of DE to be used. DE/x/y/z where x how to select individuals to be pertubed, y the number of difference vector to be used and z the crossover type. One of the most common variant is DE/rand/1/bin. F : float The weight to be used during the crossover. CR : float The probability the individual exchanges variable values from the donor vector. dither : {{'no', 'scalar', 'vector'}} One strategy to introduce adaptive weights (F) during one run. The option allows the same dither to be used in one iteration ('scalar') or a different one for each individual ('vector). jitter : bool Another strategy for adaptive weights (F). Here, only a very small value is added or subtracted to the weight used for the crossover for each individual. """ _, self.var_selection, self.var_n, self.var_mutation, = variant.split( "/") if self.var_mutation == "exp": mutation = ExponentialCrossover(CR) elif self.var_mutation == "bin": mutation = UniformCrossover(CR) super().__init__(pop_size=pop_size, sampling=sampling, selection=RandomSelection(), crossover=DifferentialEvolutionCrossover( weight=F, dither=dither, jitter=jitter), mutation=mutation, survival=None, **kwargs) self.func_display_attrs = disp_single_objective
def __init__(self, variant="DE/rand/1/bin", CR=0.5, F=0.3, dither="vector", jitter=False, selection=None, crossover=None, mutation=None, **kwargs): _, sel, n_diff, mut, = variant.split("/") self.variant = sel self.n_diffs = int(n_diff) if "-to-" in self.variant: self.n_diffs += 1 if selection is None: selection = DESelection(sel) if mutation is None: if mut == "exp": mutation = ExponentialCrossover(CR) elif mut == "bin": mutation = BiasedCrossover(CR) if crossover is None: crossover = DifferentialEvolutionCrossover(n_diffs=self.n_diffs, weight=F, dither=dither, jitter=jitter) super().__init__(selection, crossover, mutation, **kwargs)
def __init__(self, variant, CR, F, dither, jitter, **kwargs): _, self.var_selection, self.var_n, self.var_mutation, = variant.split("/") set_if_none(kwargs, 'pop_size', 200) set_if_none(kwargs, 'sampling', LatinHypercubeSampling(criterion="maxmin", iterations=100)) set_if_none(kwargs, 'crossover', DifferentialEvolutionCrossover(weight=F, dither=dither, jitter=jitter)) set_if_none(kwargs, 'selection', RandomSelection()) if self.var_mutation == "exp": set_if_none(kwargs, 'mutation', ExponentialCrossover(CR)) elif self.var_mutation == "bin": set_if_none(kwargs, 'mutation', UniformCrossover(CR)) set_if_none(kwargs, 'survival', None) super().__init__(**kwargs) self.func_display_attrs = disp_single_objective