Skip to content

Commit

Permalink
Typo in TournamentSelection: "random_permuations" should be "random_p…
Browse files Browse the repository at this point in the history
…ermutations" #669
  • Loading branch information
blankjul committed Dec 4, 2024
1 parent 28789d3 commit ddb89b8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pymoo/algorithms/moo/ctaea.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pymoo.util.display.multi import MultiObjectiveOutput
from pymoo.util.dominator import Dominator
from pymoo.util.function_loader import load_function
from pymoo.util.misc import has_feasible, random_permuations
from pymoo.util.misc import has_feasible, random_permutations
from pymoo.util.nds.non_dominated_sorting import NonDominatedSorting


Expand Down Expand Up @@ -63,7 +63,7 @@ def _do(self, problem, Hm, n_select, n_parents, **kwargs):
n_random = n_select * n_parents * self.pressure
n_perms = math.ceil(n_random / n_pop)
# get random permutations and reshape them
P = random_permuations(n_perms, n_pop)[:n_random]
P = random_permutations(n_perms, n_pop)[:n_random]
P = np.reshape(P, (n_select * n_parents, self.pressure))
if Pc <= Pd:
# Choose from DA
Expand Down
21 changes: 9 additions & 12 deletions pymoo/algorithms/moo/pinsga2.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import numpy as np
import sys

from abc import ABC, abstractmethod

import numpy as np

from pymoo.algorithms.base.genetic import GeneticAlgorithm
from pymoo.algorithms.moo.nsga2 import binary_tournament
from pymoo.docs import parse_doc_string
from pymoo.operators.crossover.sbx import SBX
from pymoo.operators.mutation.pm import PM
from pymoo.operators.survival.rank_and_crowding import RankAndCrowding
from pymoo.operators.sampling.rnd import FloatRandomSampling
from pymoo.operators.selection.tournament import compare, TournamentSelection
from pymoo.operators.selection.tournament import TournamentSelection
from pymoo.operators.survival.rank_and_crowding import RankAndCrowding
from pymoo.termination.default import DefaultMultiObjectiveTermination
from pymoo.util.display.multi import MultiObjectiveOutput
from pymoo.util.dominator import Dominator
from pymoo.util.vf_dominator import VFDominator
from pymoo.util.misc import has_feasible
from pymoo.util.reference_direction import select_points_with_maximum_distance
from pymoo.util import value_functions as mvf
from pymoo.util.display.multi import MultiObjectiveOutput
from pymoo.util.nds.non_dominated_sorting import NonDominatedSorting

from pymoo.algorithms.moo.nsga2 import binary_tournament
from pymoo.algorithms.moo.nsga2 import RankAndCrowdingSurvival
from pymoo.util.reference_direction import select_points_with_maximum_distance
from pymoo.util.vf_dominator import VFDominator


# =========================================================================================================
Expand Down
4 changes: 2 additions & 2 deletions pymoo/operators/selection/rnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from pymoo.core.selection import Selection
from pymoo.util.misc import random_permuations
from pymoo.util.misc import random_permutations


class RandomSelection(Selection):
Expand All @@ -16,7 +16,7 @@ def _do(self, _, pop, n_select, n_parents, **kwargs):
n_perms = math.ceil(n_random / len(pop))

# get random permutations and reshape them
P = random_permuations(n_perms, len(pop))[:n_random]
P = random_permutations(n_perms, len(pop))[:n_random]

return np.reshape(P, (n_select, n_parents))

Expand Down
4 changes: 2 additions & 2 deletions pymoo/operators/selection/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from pymoo.core.selection import Selection
from pymoo.util.misc import random_permuations
from pymoo.util.misc import random_permutations


class TournamentSelection(Selection):
Expand Down Expand Up @@ -42,7 +42,7 @@ def _do(self, _, pop, n_select, n_parents=1, **kwargs):
n_perms = math.ceil(n_random / len(pop))

# get random permutations and reshape them
P = random_permuations(n_perms, len(pop))[:n_random]
P = random_permutations(n_perms, len(pop))[:n_random]
P = np.reshape(P, (n_select * n_parents, self.pressure))

# compare using tournament function
Expand Down
2 changes: 1 addition & 1 deletion pymoo/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def parameter_less_constraints(F, CV, F_max=None):
return F


def random_permuations(n, l, concat=True):
def random_permutations(n, l, concat=True):
P = []
for i in range(n):
P.append(np.random.permutation(l))
Expand Down

0 comments on commit ddb89b8

Please sign in to comment.