public static Node evolveProgram ( Map < double [ ] , Double > data ) { TreeFactory factory = new TreeFactory ( 2 , // Number of parameters passed into each program. 4 , // Maximum depth of generated trees. Probability . EVENS , // Probability that a node is a function node. new Probability ( 0.6d ) ) ; // Probability that other nodes are params rather than constants. List < EvolutionaryOperator < Node > > operators = new ArrayList < EvolutionaryOperator < Node > > ( 3 ) ; operators . add ( new TreeMutation ( factory , new Probability ( 0.4d ) ) ) ; operators . add ( new TreeCrossover ( ) ) ; operators . add ( new Simplification ( ) ) ; TreeEvaluator evaluator = new TreeEvaluator ( data ) ; EvolutionEngine < Node > engine = new GenerationalEvolutionEngine < Node > ( factory , new EvolutionPipeline < Node > ( operators ) , evaluator , new RouletteWheelSelection ( ) , new MersenneTwisterRNG ( ) ) ; engine . addEvolutionObserver ( new EvolutionLogger < Node > ( ) ) ; return engine . evolve ( 1000 , 5 , new TargetFitness ( 0d , evaluator . isNatural ( ) ) ) ; }
Evolve a function to fit the specified data .