RedirectLinkMutation extends TWEANNMutation { public void mutate(Genotype<TWEANN> genotype) { LinkGene lg = ((TWEANNGenotype) genotype).deleteLinkMutation(); if(lg != null) ((TWEANNGenotype) genotype).linkMutation(lg.sourceInnovation, lg.weight); } RedirectLinkMutation(); void mutate(Genotype<TWEANN> genotype);  }
@SuppressWarnings("unchecked") @Test public void test() { TWEANNGenotype copy = (TWEANNGenotype) tg1.copy(); ArrayList<LinkGene> links = (ArrayList<LinkGene>) tg1.links.clone(); int numLinks = links.size(); do { rlm.mutate(copy); } while(copy.links.size() != numLinks && (copy = (TWEANNGenotype) tg1.copy()) != null); LinkGene missingLink = null; for(LinkGene link : links) { if(!copy.links.contains(link)){ missingLink = link; } } assertTrue("all links match!", missingLink != null); LinkGene foundLink = null; for(LinkGene link : copy.links) { if(link.weight == missingLink.weight) { foundLink = link; } } assertTrue(foundLink != null); }