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 Exp 23 extends MathCommand { 24 25 private final static String CVS_REVISION = "$Revision: 1.6 $"; 26 27 public Exp(final GPConfiguration a_conf, Class a_type) 28 throws InvalidConfigurationException { 29 super(a_conf, 1, a_type); 30 } 31 32 public String toString() { 33 return "Exp(&1)"; 34 } 35 36 42 public String getName() { 43 return "Exp"; 44 } 45 46 public int execute_int(ProgramChromosome c, int n, Object [] args) { 47 int i = c.execute_int(n, 0, args); 48 return (int) Math.exp(Math.max( -10000.0f, Math.min(i, 20.0f))); 50 } 51 52 public float execute_float(ProgramChromosome c, int n, Object [] args) { 53 float f = c.execute_float(n, 0, args); 54 return (float) Math.exp(Math.max( -10000.0f, Math.min(f, 20.0f))); 56 } 57 58 public double execute_double(ProgramChromosome c, int n, Object [] args) { 59 double f = c.execute_double(n, 0, args); 60 return Math.exp(Math.max( -10000.0, Math.min(f, 20.0))); 62 } 63 64 public Object execute_object(ProgramChromosome c, int n, Object [] args) { 65 return ( (Compatible) c.execute_object(n, 0, args)).execute_exp(); 66 } 67 68 protected interface Compatible { 69 public Object execute_exp(); 70 } 71 } 72 | Popular Tags |