Class BNPReplacement<T>

java.lang.Object
org.cicirello.search.evo.BNPReplacement<T>
Type Parameters:
T - the representation of population members
All Implemented Interfaces:
Splittable<ReplacementStrategy<T>>, ReplacementStrategy<T>

public final class BNPReplacement<T> extends Object implements ReplacementStrategy<T>
The Best-non-penalized (BNP) is a replacement strategy that promotes proper diversity levels during the evolutionary process. It is an explicit diversity management technique that balances the search toward exploration at initial stages and shifts the balance toward intensification at the end of the optimization process. Thus, premature convergence and other issues may be avoided. At each iteration, the BNP selects as survivors the candidate solutions that are sufficiently distant from one another. Thus, a distance metric among the candidate solutions must be defined. Initially, the distance threshold is computed based on the mean distance between all candidate solutions. Then, such a threshold is linearly decreased.

The BNP has been demonstrated to be effective in continuous and combinatorial optimization problems:

Cornejo-Acosta, J. A., Segura, C., Garcia-Diaz, J., and Perez-Sansalvador, J. C. (2026). Diversity Management Techniques for the Upper-Bounded Hamiltonian p-Median Problem. Mathematical and Computational Applications, 31(2). https://doi.org/10.3390/mca31020064

Segura, C., Lugo, L., Miranda, G., and Serrano Cardenas, E. D. (2024). PACE Solver Description: CIMAT_Team. In E. Bonnet and P. Rzazewski (Eds.), 19th International Symposium on Parameterized and Exact Computation (IPEC 2024) (Vol. 321, p. 31:1-31:4). Schloss Dagstuhl – Leibniz-Zentrum fur Informatik. https://doi.org/10.4230/LIPIcs.IPEC.2024.31

Lugo, L., Segura, C., and Miranda, G. (2022). A diversity-aware memetic algorithm for the linear ordering Problem. Memetic Computing, 14(4), 395-409. https://doi.org/10.1007/s12293-022-00378-5

Hernandez Constantino, O., and Segura, C. (2022). A parallel memetic algorithm with explicit management of diversity for the job shop scheduling problem. Applied Intelligence, 52(1), 141–153. https://doi.org/10.1007/s10489-021-02406-2

Chacón Castillo, J., and Segura, C. (2020). Differential evolution with enhanced diversity maintenance. Optimization Letters, 14(6), 1471–1490. https://doi.org/10.1007/s11590-019-01454-5

Romero Ruiz, E., and Segura, C. (2018). Memetic Algorithm with Hungarian Matching Based Crossover and Diversity Preservation. Computación y Sistemas, 22(2), 347–361. https://doi.org/10.13053/CyS-22-2-2951

Segura, C., Hernandez-Aguirre, A., Luna, F., and Alba, E. (2017). Improving Diversity in Evolutionary Algorithms: New Best Solutions for Frequency Assignment. IEEE Transactions on Evolutionary Computation, 21(4), 539–553. https://doi.org/10.1109/TEVC.2016.2641477

  • Constructor Details

    • BNPReplacement

      public BNPReplacement(BiFunction<T,T,Double> distanceFunction)
      Constructs the replacement strategy, with a default initialDiversityFactor 0.4.
      Parameters:
      distanceFunction - Function to measure the distance between two candidate solutions.
    • BNPReplacement

      public BNPReplacement(BiFunction<T,T,Double> distanceFunction, double initialDiversityFactor)
      Constructs the replacement strategy.
      Parameters:
      distanceFunction - Function to measure the distance between two candidate solutions.
      initialDiversityFactor - Factor to modify the initial diversity threshold.
  • Method Details

    • replace

      public void replace(PopulationCandidates.IntegerFitness<T> parentPopulation, PopulationCandidates.IntegerFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize)
      Description copied from interface: ReplacementStrategy
      Chooses the members of the population of the next generation from among those currently in the population and the pool of candidates formed from crossover and mutation. Implementations must not attempt to further manipulate the state of the individuals in these sets. Doing so can lead to undefined behavior.
      Specified by:
      replace in interface ReplacementStrategy<T>
      Parameters:
      parentPopulation - the current population
      childPopulation - the members of the population chosen by the selection operator which have already gone through crossover, mutation, both, or neither (based on crossover rates, mutation rates, etc)
      replacements - records which members of the parent and child populations serve as replacements
      targetPopulationSize - the size of the target population for the next generation. In most cases this will likely be the same as parentPopulation.size(). But, do not make that assumption in your implementation to allow less common EA structures where population size may vary
    • replace

      public void replace(PopulationCandidates.DoubleFitness<T> parentPopulation, PopulationCandidates.DoubleFitness<T> childPopulation, ReplacementStrategy.Replacements replacements, int targetPopulationSize)
      Description copied from interface: ReplacementStrategy
      Chooses the members of the population of the next generation from among those currently in the population and the pool of candidates formed from crossover and mutation. Implementations must not attempt to further manipulate the state of the individuals in these sets. Doing so can lead to undefined behavior.
      Specified by:
      replace in interface ReplacementStrategy<T>
      Parameters:
      parentPopulation - the current population
      childPopulation - the members of the population chosen by the selection operator which have already gone through crossover, mutation, both, or neither (based on crossover rates, mutation rates, etc)
      replacements - records which members of the parent and child populations serve as replacements
      targetPopulationSize - the size of the target population for the next generation. In most cases this will likely be the same as parentPopulation.size(). But, do not make that assumption in your implementation to allow less common EA structures where population size may vary
    • split

      public BNPReplacement<T> split()
      Description copied from interface: Splittable
      Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms. The state of the object that is returned may or may not be identical to that of the original. Thus, this is a distinct concept from the functionality of the Copyable interface. Classes that implement this interface must ensure that the object returned performs the same functionality, and that it does not share any state data that would be either unsafe or inefficient for concurrent access by multiple threads. The split method is allowed to simply return the this reference, provided that it is both safe and efficient for multiple threads to share a single copy of the Splittable object. The intention is to provide a multithreaded search with the capability to provide spawned threads with their own distinct search operators. Such multithreaded algorithms can call the split method for each thread it spawns to generate a functionally identical copy of the operator, but with independent state.
      Specified by:
      split in interface Splittable<T>
      Returns:
      A functionally identical copy of the object, or a reference to this if it is both safe and efficient for multiple threads to share a single instance of this Splittable object.
    • setInitialDiversityFactor

      public void setInitialDiversityFactor(double initialDiversityFactor)
      Sets the initial diversity factor. The default value is 0.4.
      Parameters:
      initialDiversityFactor - the initial diversity factor
    • init

      public void init(int generations)
      Initializes the replacement strategy with the specified number of generations.
      Specified by:
      init in interface ReplacementStrategy<T>
      Parameters:
      generations - the number of generations to run the algorithm
      Throws:
      IllegalArgumentException - if generations is less than or equal to 0