How to add mutation probability to the NSGA-II code from Pymoo?

77 views Asked by At

My code is Pymoo: Multi-Objective Optimization in Python (NSGA-II). The mutation is a polynomial mutation (PM). The code doesn't involve mutation probability, as shown below:

class NSGA2(GeneticAlgorithm):

def __init__(self,
             pop_size=100,
             sampling=FloatRandomSampling(),
             selection=TournamentSelection(func_comp=binary_tournament),
             crossover=SBX(eta=60, prob=0.6),
             mutation=PM(eta=40),
             survival=RankAndCrowdingSurvival(),
             output=MultiObjectiveOutput(),
             **kwargs):
    super().__init__(
        pop_size=pop_size,
        sampling=sampling,
        selection=selection,
        crossover=crossover,
        mutation=mutation,
        survival=survival,
        output=output,
        advance_after_initial_infill=True,
        **kwargs)

and as explained in the pymoo site, "This mutation follows the same probability distribution as the simulated binary crossover."

I can't interpret the above sentence; additionally, I don't know if the mutation probability is integrated into the code or not.

I also want to add adaptive mutation to the code Is it possible?

To treat the mutation problem, I used the maximum and minimum ETA parameters as shown below:

maxeta, mineta = 100, 20 class MyCallback(Callback): def init(self) -> None: super().init()

def notify(self, algorithm):
    print("algorithm.n_gen: ", algorithm.n_gen)
    eta = (maxeta-mineta)*(algorithm.n_gen/n_gen) + mineta
    print("eta: ", eta)
    algorithm.mating.mutation = PM(eta=eta, )
0

There are 0 answers