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

jeco.core.problems.Rastringin Maven / Gradle / Ivy

The newest version!
package jeco.core.problems;

import java.util.logging.Logger;

import jeco.core.problem.Problem;
import jeco.core.problem.Solution;
import jeco.core.problem.Solutions;
import jeco.core.problem.Variable;
import jeco.core.util.random.RandomGenerator;

public class Rastringin extends Problem> {
	private static final Logger logger = Logger.getLogger(Rastringin.class.getName());

	protected double bestValue = Double.POSITIVE_INFINITY;

	public Rastringin(Integer numberOfVariables) {
		super(numberOfVariables, 1);
		for (int i = 0; i < numberOfVariables; i++) {
			lowerBound[i] = -5.12;
			upperBound[i] = 5.12;
		}
	}

	public Solutions> newRandomSetOfSolutions(int size) {
		Solutions> solutions = new Solutions>();
		for (int i=0; i> solI = new Solution>(numberOfObjectives);
			for (int j = 0; j < numberOfVariables; ++j) {
				Variable varJ = new Variable(RandomGenerator.nextDouble(lowerBound[j], upperBound[j]));
				solI.getVariables().add(varJ);
			}
			solutions.add(solI);
		}
		return solutions;
	}
	
	public void evaluate(Solutions> solutions) {
		for(Solution> solution : solutions)
			evaluate(solution);
	}

	public void evaluate(Solution> solution) {
		double fitness = 10*super.numberOfVariables;
		for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy