ActivationFunctionMutation extends TWEANNMutation { @Override public void mutate(Genotype<TWEANN> genotype) { TWEANNGenotype g = (TWEANNGenotype) genotype; ArrayList<NodeGene> nodes = g.nodes; NodeGene node = RandomNumbers.randomElement(nodes); node.ftype = ActivationFunctions.randomFunction(); } ActivationFunctionMutation(); @Override void mutate(Genotype<TWEANN> genotype);  }
@Test public void test() { ArrayList<NodeGene> originalNodes = tg1.nodes; ArrayList<Integer> originalFunc = new ArrayList<Integer>(); ArrayList<Integer> mutatedFunc = new ArrayList<Integer>(); ActivationFunctionMutation afm = new ActivationFunctionMutation(); TWEANNGenotype tg2 = (TWEANNGenotype) tg1.copy(); afm.mutate(tg2); tg2.mutate(); for(int i = 0; i < originalNodes.size(); i++) { originalFunc.add(tg1.nodes.get(i).ftype); mutatedFunc.add(tg2.nodes.get(i).ftype); } System.out.println("original functions: " + originalFunc.toString()); System.out.println("new functions: " + mutatedFunc.toString()); assertFalse(originalFunc.equals(mutatedFunc)); }