evomo.operators.selection#
Submodules#
Functions#
|
Return the |
|
Compute the crowding distance for a set of solutions in multi-objective optimization. |
|
Perform environmental selection based on non-domination rank and crowding distance. |
|
Compute the non-domination rank for a set of solutions in multi-objective optimization. |
|
Perform the Reference Vector Guided Evolutionary Algorithm (RVEA) selection process. |
Package Contents#
- evomo.operators.selection.get_non_dominate_backend(backend: str = 'torch') types.ModuleType#
Return the
torch(default) or experimentaltritonoperator module.Call this during setup, outside
torch.compile. Triton is imported only when explicitly requested. The returned module exposes non_dominate_rank, dominate_relation, crowding_distance and nd_environmental_selection.
- evomo.operators.selection.crowding_distance(costs: torch.Tensor, mask: torch.Tensor)#
Compute the crowding distance for a set of solutions in multi-objective optimization.
The crowding distance is a measure of the diversity of solutions within a Pareto front.
- Parameters:
costs – A 2D tensor where each row represents a solution, and each column represents an objective.
mask – A 1D boolean tensor indicating which solutions should be considered.
- Returns:
A 1D tensor containing the crowding distance for each solution.
- evomo.operators.selection.nd_environmental_selection(x: torch.Tensor, f: torch.Tensor, topk: int, cv: torch.Tensor = None)#
Perform environmental selection based on non-domination rank and crowding distance.
Ranking stops after the complete front containing the topk-th solution. Negative or nonfinite total constraint violations require full ranking to preserve the CV-first selection order. Returned ranks are always complete for the selected individuals; use non_dominate_rank for all input ranks.
- Parameters:
x – A 2D tensor where each row represents a solution, and each column represents a decision variable.
f – A 2D tensor where each row represents a solution, and each column represents an objective.
topk – The number of solutions to select.
cv – An optional tensor containing the constraint violations of the solutions.
- Returns:
A tuple of five values: - x: The selected solutions. - f: The corresponding objective values. - rank: The non-domination rank of the selected solutions. - crowding_dis: The crowding distance of the selected solutions. - cv: The selected constraint violations, or
Nonefor an unconstrained problem.
- evomo.operators.selection.non_dominate_rank(x: torch.Tensor, cv: torch.Tensor = None) torch.Tensor#
Compute the non-domination rank for a set of solutions in multi-objective optimization.
The non-domination rank is a measure of the Pareto optimality of each solution.
- Parameters:
x – A 2D tensor where each row represents a solution, and each column represents an objective.
cv – An optional tensor containing the constraint violations of the solutions.
- Returns:
A 1D tensor containing the zero-based non-domination rank for each solution. Solutions in the first Pareto front have rank 0.
- evomo.operators.selection.ref_vec_guided(x: torch.Tensor, f: torch.Tensor, v: torch.Tensor, theta: torch.Tensor)#
Perform the Reference Vector Guided Evolutionary Algorithm (RVEA) selection process.
This function selects solutions based on the Reference Vector Guided Evolutionary Algorithm. It calculates the distances and angles between solutions and reference vectors, and returns the next set of solutions to be evolved.
- Parameters:
x – A tensor of shape (n, d) representing the current population solutions.
f – A tensor of shape (n, m) representing the objective values for each solution.
v – A tensor of shape (r, m) representing the reference vectors.
theta – A tensor representing the parameter theta used in the APD calculation.
- Returns:
A tuple containing: - next_x: The next selected solutions. - next_f: The objective values of the next selected solutions.
- Note:
The function computes the distances between the solutions and reference vectors, and selects the solutions with the minimum APD. It currently uses a suboptimal selection implementation, and future improvements will optimize the process using a segment_sort or segment_argmin in CUDA.