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

net.sourceforge.cilib.util.selection.weighting.SpecialisedRatio Maven / Gradle / Ivy

Go to download

A library of composable components enabling simpler Computational Intelligence

The newest version!
/**           __  __
 *    _____ _/ /_/ /_    Computational Intelligence Library (CIlib)
 *   / ___/ / / / __ \   (c) CIRG @ UP
 *  / /__/ / / / /_/ /   http://cilib.net
 *  \___/_/_/_/_.___/
 */
package net.sourceforge.cilib.util.selection.weighting;

import static com.google.common.base.Preconditions.checkState;
import java.util.List;
import net.sourceforge.cilib.pso.particle.ParticleBehavior;

public class SpecialisedRatio implements ParticleBehaviorRatio {
    private List behaviors;
    private List weights;

    @Override
    public double getRatio(ParticleBehavior particleBehavior) {
        checkState(behaviors.size() > 0, "You must add particle behaviors to the behavior pool first.");
        checkState(weights.size() == behaviors.size(), "Make sure the behavior pool is the same size as the weights list.");

        return weights.get(behaviors.indexOf(particleBehavior));
    }

    public void setBehaviors(List behaviors) {
        this.behaviors = behaviors;
    }

    public void setWeights(List weights) {
        this.weights = weights;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy