/********************************************************************** # 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: Ackley Function

*

Description: Minimize f(x) = 20+e-20*exp(-0.2*(sqrt((1/n)*sum(x(i)^2))-exp((1/n)*sum(cos(2*Pi*x(i))) where X = [-30, 30] by .001

*

Copyright: EWASystems Copyright (c) 1998 - 2005

*

Company: EWASystems

* @author Lincoln Evans-Beauchamp * @version 1.0 */ public class Ackley extends GeneticProblem { /** * Problem Constructor */ public Ackley() { super("Ackley Function", "Minimize f(x) = 20+e-20*exp(-0.2*(sqrt((1/n)*sum(x(i)^2))-exp((1/n)*sum(cos(2*Pi*x(i))) where X = [-30, 30] by .001"); } /** * 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, f2 = 0d; for (int i=0; i