net.sourceforge.cilib.util.functions.Algorithms 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.util.functions;
import net.sourceforge.cilib.algorithm.AbstractAlgorithm;
import net.sourceforge.cilib.algorithm.Algorithm;
import net.sourceforge.cilib.algorithm.population.SinglePopulationBasedAlgorithm;
import net.sourceforge.cilib.entity.Entity;
import net.sourceforge.cilib.problem.Problem;
import net.sourceforge.cilib.problem.solution.OptimisationSolution;
import fj.F;
import fj.F2;
public final class Algorithms {
public static F getBestSolution() {
return new F() {
@Override
public OptimisationSolution f(A a) {
return a.getBestSolution();
}
};
}
public static F> getSolutions() {
return new F>() {
@Override
public Iterable f(A a) {
return a.getSolutions();
}
};
}
public static F performIteration() {
return new F() {
@Override
public A f(A a) {
a.performIteration();
return a;
}
};
}
public static F iterateUnlessDone() {
return new F() {
@Override
public A f(A a) {
if (!a.isFinished()) {
a.performIteration();
}
return a;
}
};
}
public static F iterateUntilDone() {
return new F() {
@Override
public A f(A a) {
while (!a.isFinished()) {
a.performIteration();
}
return a;
}
};
}
public static F performInitialisation() {
return new F() {
@Override
public A f(A a) {
a.performInitialisation();
return a;
}
};
}
public static F getIterations() {
return new F() {
@Override
public Integer f(A a) {
return a.getIterations();
}
};
}
public static F2 setOptimisationProblem() {
return new F2() {
@Override
public A f(Problem a, A b) {
b.setOptimisationProblem(a);
return b;
}
};
}
public static F getOptimisationProblem() {
return new F() {
@Override
public Problem f(A a) {
return a.getOptimisationProblem();
}
};
}
public static F isFinished() {
return new F() {
@Override
public Boolean f(A a) {
return a.isFinished();
}
};
}
public static F run() {
return new F() {
@Override
public A f(A a) {
((AbstractAlgorithm) a).run();
return a;
}
};
}
public static F initialise() {
return new F() {
@Override
public A f(A a) {
((AbstractAlgorithm) a).performInitialisation();
return a;
}
};
}
public static F> getTopology() {
return new F>() {
@Override
public fj.data.List extends Entity> f(A a) {
return a.getTopology();
}
};
}
public static F2, ? extends A, A> setTopology() {
return new F2, A, A>() {
@Override
public A f(fj.data.List extends Entity> a, A b) {
b.setTopology(a);
return b;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy