net.sourceforge.cilib.functions.continuous.hybrid.SimpleHybridFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cilib-library Show documentation
Show all versions of cilib-library Show documentation
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.functions.continuous.hybrid;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.cilib.functions.ContinuousFunction;
import net.sourceforge.cilib.type.types.container.Vector;
/**
* Implementation to create a simple hybrid function that is composed of
* several continuous functions. The hybrid function value is the sum
* of the individual function values.
*/
public class SimpleHybridFunction extends ContinuousFunction {
private final List functions;
public SimpleHybridFunction() {
this.functions = new ArrayList();
}
/**
* {@inheritDoc}
*/
@Override
public Double f(Vector input) {
double result = 0.0;
for(ContinuousFunction function : functions) {
result += function.f(input);
}
return result;
}
/**
* Adds a function to the hybrid function.
* @param function
*/
public void addFunction(ContinuousFunction function) {
functions.add(function);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy