anyoptimization / pymoo

NSGA2, NSGA3, R-NSGA3, MOEAD, Genetic Algorithms (GA), Differential Evolution (DE), CMAES, PSO
https://pymoo.org
Apache License 2.0
2.28k stars 390 forks source link

How to do NSGA3 survival selection ? #138

Closed Ellyuca closed 3 years ago

Ellyuca commented 3 years ago

Hi! First of all I want to apologize for my ignorance regarding this library. I just found out about it and I have little knowledge about how to use it.

I have the following situation:

I wanted to ask if it's possible to apply only the survival selection (non-dominated sorting + Reference points based selection as presented in the paper ) from NSGA3 to select the best k individuals from a list of N individuals based on their pre-computed fitness values.

I am greatly thankful for any help, tips and advice. Thank you everyone for your time.

blankjul commented 3 years ago

Hi! Sorry for my late reply. Sure it is possible, see the code below.

import numpy as np
from pymoo.algorithms.nsga3 import ReferenceDirectionSurvival

from pymoo.factory import get_reference_directions, Problem
from pymoo.model.population import Population

F = np.random.random((182, 3))

pop = Population.new(F=F)

ref_dirs = get_reference_directions("das-dennis", 3, n_partitions=12)

survival = ReferenceDirectionSurvival(ref_dirs)
survivors = survival.do(Problem(n_var=-1, n_obj=3, n_constr=0), pop, 91)
Ellyuca commented 3 years ago

Hi julesy89. Thank you very much for your reply. I will test it as soon as possible and see what happens.

Stay safe and healthy, Best Elly.

Edit: everything seems to be working just as I needed. Thank you once again!

blankjul commented 3 years ago

Great! Glad I could help.