Version: 0.5.0

# Initialization¶

An algorithm can be either initialized using the object or directly by constructing an convenience. Both has their pro and cons.

## Object¶

Directly initializing the object keeps the code clean and if you use an idea lets you quickly jump to the definition of the algorithm and find hyperparameters to modify.

[1]:

from pymoo.algorithms.moo.nsga2 import NSGA2
algorithm = NSGA2()


## Convenience¶

An initialization through the convenience function does not need to add any new import, and it can be helpful if multiple algorithms shall be run on the same problem. This requires only changing the corresponding string. However, this only works if the objects share the same parameters or do not need additional ones.

[2]:

from pymoo.factory import get_algorithm
algorithm = get_algorithm("nsga2")