1 10 package org.jgap.gp.function; 11 12 import org.jgap.*; 13 import org.jgap.gp.*; 14 import org.jgap.gp.impl.*; 15 16 22 public class Cosine 23 extends MathCommand { 24 25 private final static String CVS_REVISION = "$Revision: 1.5 $"; 26 27 public Cosine(final GPConfiguration a_conf, Class type) 28 throws InvalidConfigurationException { 29 super(a_conf, 1, type); 30 } 31 32 public String toString() { 33 return "cosine &1"; 34 } 35 36 42 public String getName() { 43 return "Cosine"; 44 } 45 46 public float execute_float(ProgramChromosome c, int n, Object [] args) { 47 float f = c.execute_float(n, 0, args); 48 return (float) Math.cos(Math.max( -10000.0f, Math.min(f, 10000.0f))); 50 } 51 52 public double execute_double(ProgramChromosome c, int n, Object [] args) { 53 double d = c.execute_double(n, 0, args); 54 return Math.cos(Math.max( -10000.0, Math.min(d, 10000.0))); 56 } 57 58 public Object execute_object(ProgramChromosome c, int n, Object [] args) { 59 return ( (Compatible) c.execute_object(n, 0, args)).execute_cosine(); 60 } 61 62 protected interface Compatible { 63 public Object execute_cosine(); 64 } 65 } 66 | Popular Tags |