evomo.algorithms.nsga2#
Classes#
A tensorized implementation of the Non-dominated Sorting Genetic Algorithm II (NSGA-II) |
Module Contents#
- class evomo.algorithms.nsga2.NSGA2(pop_size: int, n_objs: int, lb: torch.Tensor, ub: torch.Tensor, selection_op: Callable | None = None, mutation_op: Callable | None = None, crossover_op: Callable | None = None, device: torch.device | None = None)#
Bases:
evox.core.AlgorithmA tensorized implementation of the Non-dominated Sorting Genetic Algorithm II (NSGA-II) for multi-objective optimization problems.
- References:
- [1] K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan, “A fast and elitist multiobjective genetic algorithm: NSGA-II,”
IEEE Transactions on Evolutionary Computation, vol. 6, no. 2, pp. 182-197, 2002. Available: https://ieeexplore.ieee.org/document/996017
- [2] Z. Liang, H. Li, N. Yu, K. Sun, and R. Cheng, “Bridging Evolutionary Multiobjective Optimization and
GPU Acceleration via Tensorization,” IEEE Transactions on Evolutionary Computation, 2025. Available: https://ieeexplore.ieee.org/document/10944658
Initialize NSGA-II with rank and crowding-distance selection.
- Parameters:
pop_size (int) – Required. Requested number of candidate solutions. Use a positive integer; algorithm-specific minimums and reference-vector sampling are described below.
n_objs (int) – Required. Number of objectives, matching the second dimension of the problem’s objective tensor. Objectives are minimized; this library targets two or more objectives.
lb (torch.Tensor) – Required. Lower decision bounds of shape
(D,), whereDis the number of decision variables. Use floating-point bounds with the same shape, dtype and device asub, andlb <= ubelementwise.ub (torch.Tensor) – Required. Upper decision bounds of shape
(D,). The decision dimension is inferred from the bounds, rather than passed separately. Matchlbin shape, dtype and device.selection_op (Callable or None) – Default:
None. Mating selection callableselection_op(pop_size, keys) -> indices.keysis a list of one-dimensional sort-key tensors for crowding distance, rank and, when present, constraints. Returnpop_sizeparent indices on the population device.Noneselects EvoX’stournament_selection_multifit. This does not replace environmental selection.mutation_op (Callable or None) – Default:
None. Mutation callablemutation_op(offspring, lb, ub) -> mutated_offspring. Input and output are decision tensors of shape(B, D); preserve device and return an appropriate decision dtype.Noneselects EvoX’spolynomial_mutation.crossover_op (Callable or None) – Default:
None. Crossover callablecrossover_op(parents) -> offspringreceiving a two-dimensional decision tensor.Noneselects EvoX’ssimulated_binary. Preserve the decision dimension and device, and produce the offspring count expected by this algorithm.device (torch.device or None) – Default:
None. Execution device.Noneusestorch.get_default_device(); it does not infer the device from the bounds. Bounds are copied to this device. Passtorch.device('cuda')explicitly for GPU execution.
Note
Use this algorithm through a workflow that connects the problem’s evaluation method. Call
workflow.init_step()beforeworkflow.step()or compiling the step. Evaluation accepts an objective tensor of shape(B, n_objs)or(fitness, constraint_violation); violations are retained in selection.- init_step()#
Perform the initialization step of the workflow.
- step()#
Advance optimization and update population and fitness state in place.
Invoke through
workflow.step()after initialization. The caller controls termination.- Returns:
None; results are stored in algorithm state.