All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.cilib.niching.merging.detection.CompositeMergeDetection Maven / Gradle / Ivy

/**           __  __
 *    _____ _/ /_/ /_    Computational Intelligence Library (CIlib)
 *   / ___/ / / / __ \   (c) CIRG @ UP
 *  / /__/ / / / /_/ /   http://cilib.net
 *  \___/_/_/_/_.___/
 */
package net.sourceforge.cilib.niching.merging.detection;

import fj.F;
import fj.data.List;
import fj.function.Booleans;
import net.sourceforge.cilib.algorithm.population.SinglePopulationBasedAlgorithm;

public class CompositeMergeDetection extends MergeDetection {

    private List detectors;

    public CompositeMergeDetection() {
        MergeDetection m = new AlwaysMergeDetection();
        this.detectors = List.list(m);
    }

    @Override
    public Boolean f(final SinglePopulationBasedAlgorithm a, final SinglePopulationBasedAlgorithm b) {
        return Booleans.and(detectors.map(new F() {
            @Override
            public Boolean f(MergeDetection c) {
                return c.f(a, b);
            }
        }));
    }

    public void addDetector(MergeDetection m) {
        detectors = detectors.cons(m);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy