/********************************************************************** # Copyright (c) EWA Systems Inc. 1998 - 2005 All Rights Reserved # No part of this program may be photocopied, reproduced, # or translated to another programming language without # the prior written consent of EWA Systems. **********************************************************************/ package com.ewasystems.opt.ga.test; import com.ewasystems.opt.ga.GeneticAlleleSet; import com.ewasystems.opt.ga.GeneticEngine; import com.ewasystems.opt.ga.GeneticGene; import com.ewasystems.opt.ga.GeneticProblem; import com.ewasystems.opt.ga.GeneticRunTask; /** *
Genetic Algorithm Test Case: Rastrigin Function
*Description: Minimize f(x) = 10.0*n + sum(x(i)^2 - 10.0*cos(2*Pi*x(i))) where X = [-600, 600] by .02
*Copyright: EWASystems Copyright (c) 1998 - 2005
*Company: EWASystems
* @author Lincoln Evans-Beauchamp * @version 1.0 */ public class Rastrigin extends GeneticProblem { /** * Problem Constructor */ public Rastrigin() { super("Rastrigin Function", "Minimize f(x) = 10.0*n + sum(x(i)^2 - 10.0*cos(2*Pi*x(i))) where X = [-5.12, 5.12] by .0005"); } /** * The Objective Function * @param gene The Genetic Gene to Test * @return double: The Genetic Gene's Fitness */ public double f(GeneticGene gene) { double f1 = 0d; for (int i=0; i