TWEANNGenotype implements NetworkGenotype<TWEANN> { public LinkGene getLinkBetween(long sourceInnovation, long targetInnovation) { for (LinkGene l : links) { if (l.sourceInnovation == sourceInnovation && l.targetInnovation == targetInnovation) { return l; } } return null; } TWEANNGenotype(TWEANNGenotype copy);  TWEANNGenotype(ArrayList<NodeGene> nodes, ArrayList<LinkGene> links, int neuronsPerModule,
            boolean standardMultitask, boolean hierarchicalMultitask, int archetypeIndex);  TWEANNGenotype(TWEANN tweann);  TWEANNGenotype();  TWEANNGenotype(int numIn, int numOut, int archetypeIndex);  TWEANNGenotype(int numIn, int numOut, boolean featureSelective, int ftype, int numModules, int archetypeIndex); static final LinkGene newLinkGene(long sourceInnovation, long targetInnovation, double weight, long innovation, boolean recurrent); static final LinkGene newLinkGene(long sourceInnovation, long targetInnovation, double weight, long innovation, boolean recurrent, boolean frozen); static final LinkGene newLinkGene(long sourceInnovation, long targetInnovation, double weight, long innovation, boolean active, boolean recurrent, boolean frozen); static final NodeGene newNodeGene(int ftype, int ntype, long innovation); static final NodeGene newNodeGene(int ftype, int ntype, long innovation, boolean frozen, double bias); @Override void addParent(long id); @Override List<Long> getParentIDs(); @Override final int numModules(); double numLinks(boolean recurrent); void calculateNumModules(); double lastModulesDistance(); double twoModulesDistance(int m1, int m2); @Override void mutate(); int fullyConnectedModeMutation(); int moduleMutation(boolean randomSources, int numLinks); LinkGene deleteLinkMutation(); LinkGene deleteLink(int index); void deleteRandomModeMutation(); void deleteLeastUsedModeMutation(); void weightMutation(); void allWeightMutation(RandomGenerator rand, double rate); boolean existsAlterableLink(); LinkGene randomAlterableLink(); void perturbLink(int linkIndex, double delta); void perturbLink(LinkGene lg, double delta); double linkWeight(int linkIndex); void setWeight(LinkGene lg, double w); @Override void setModuleUsage(int[] usage); @Override int[] getModuleUsage(); LinkGene getLinkBetween(long sourceInnovation, long targetInnovation); void linkMutation(); void linkMutation(long source, double weight); void addLink(long sourceInnovation, long targetInnovation, double weight, long innovation); void spliceMutation(); void spliceNode(int ftype, long newNodeInnovation, long sourceInnovation, long targetInnovation,
            double weight1, double weight2, long toLinkInnovation, long fromLinkInnovation); void weakenAllModules(double portion); void weakenModulePreference(int module, double portion); @SuppressWarnings("unchecked") @Override Genotype<TWEANN> crossover(Genotype<TWEANN> g); void crossModuleAssociations(int[] first, int[] second); @Override TWEANN getPhenotype(); @Override Genotype<TWEANN> copy(); @Override Genotype<TWEANN> newInstance(); static boolean sameStructure(TWEANNGenotype m, TWEANNGenotype o); @Override String toString(); boolean[] inputUsageProfile(); void moduleDuplication(); void addRandomPreferenceNeuron(int numInputs); void insertPreferenceNeuron(int moduleIndex); void freezePreferenceNeurons(); void freezePolicyNeurons(); boolean alternateFrozenPreferencePolicy(); void freezeInfluences(long nodeInnovation); void freezeModule(int m); void freezeNetwork(); void meltNetwork(); double maxModuleUsage(); double minModuleUsage(); double wastedModuleUsage(int maxModules); @Override long getId(); double compatibility(TWEANNGenotype g); static void sortLinkGenes(ArrayList<LinkGene> linkedGene); long biggestInnovation(); int outputStartIndex(); @Override boolean equals(Object o); static boolean smallerGenotypes; public ArrayList<NodeGene> nodes; public ArrayList<LinkGene> links; public int numIn; public int numOut; public int numModules; public int neuronsPerModule; public boolean standardMultitask; public boolean hierarchicalMultitask; public int[] moduleAssociations; public int archetypeIndex; }
@Test public void test_getLinksBetween() { TWEANNGenotype tg1 = new TWEANNGenotype(2, 1, 0); LinkGene lg = tg1.getLinkBetween(-1, -3); assertTrue(lg != null); assertTrue(lg.sourceInnovation == -1); assertTrue(lg.targetInnovation == -3); }