/********************************************************************** # 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: Rosenbrock Function
*Description: Minimize f(x) = sum(100*(x(i)-x(i-1)^2)^2 + (1-x(i-1))^2 where X = [-600, 600] by .02
*Copyright: EWASystems Copyright (c) 1998 - 2005
*Company: EWASystems
* @author Lincoln Evans-Beauchamp * @version 1.0 */ public class Rosenbrock extends GeneticProblem { /** * Problem Constructor */ public Rosenbrock() { super("Rosenbrock Function", "Minimize f(x) = sum(100*(x(i)-x(i-1)^2)^2 + (1-x(i-1))^2 where X = [-2.048, 2.048] 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; for (int i=1; i