Exemplo n.º 1
0
 public void SendFKPM(FKPMGene fkp)
 {
     if (Genes.ContainsKey(fkp.gene))
     {
         Genes [fkp.gene].SendFKPM(fkp.fkpm);
     }
     if (Regions.ContainsKey(fkp.gene))
     {
         Regions [fkp.gene].SendFKPM(fkp.fkpm);
     }
 }
Exemplo n.º 2
0
 public void SendComponent(string _id, int _start, int _end, Sense sn)
 {
     char[]   chrs = { '#' };
     string[] strs = _id.Split(chrs, 3);
     if (Genes.ContainsKey(strs [0]))
     {
         Genes [strs [0]].AddFileElement(strs [1], _start, _end);
     }
     else if (Regions.ContainsKey(strs [0]))
     {
         Regions [strs [0]].AddFileElement(strs [1], _start, _end);
     }
     else
     {
         AddRegion(strs [0], strs [1], _start, _end, sn);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Add nodes to random connection gene in genome
        /// </summary>
        private void AddNode(Random rnd, ref int innovation, ref int number, List <Gene> allGenes)
        {
            int  index = rnd.Next(0, Genes.Count);
            var  pair  = Genes.ElementAt(index);
            Gene gene  = pair.Value;

            gene.Type = GeneType.Disabled;
            Node node       = null;
            Gene firstGene  = null;
            Gene latterGene = null;
            bool exists     = FindExistingNode(gene, ref node, ref firstGene, ref latterGene, allGenes, ref innovation, ref number);

            if (!exists)
            {
                node       = new Node(NodeType.Hidden, gene.In.Layer + 1, ++number);
                firstGene  = new Gene(gene.In, node, 1f, GeneType.Enabled, ++innovation);
                latterGene = new Gene(node, gene.Out, gene.Weight, GeneType.Enabled, ++innovation);
            }
            // Check if the latter gene connection cannot be from the same layer to the same layer
            if (gene.Out.Layer == node.Layer)
            {
                IncrementLayer(node);
            }

            if (!Genes.ContainsKey(firstGene.Innovation)) // should always go to if branch
            {
                Genes.Add(firstGene.Innovation, firstGene);
                firstGene.In.OutgoingConnections.Add(firstGene);
                if (!exists)
                {
                    var g = firstGene.ShallowCopy();
                    g.Type = GeneType.AddNode;
                    allGenes.Add(g); // still points to nodes in this genome
                }
            }
            else
            {
                ;
            }
            if (!Genes.ContainsKey(latterGene.Innovation)) // should always go to if branch
            {
                Genes.Add(latterGene.Innovation, latterGene);
                latterGene.In.OutgoingConnections.Add(latterGene);
                if (!exists)
                {
                    var g = latterGene.ShallowCopy();
                    g.Type = GeneType.AddNode;
                    allGenes.Add(g); // still points to nodes in this genome
                }
            }
            else
            {
                ;
            }
            if (!Nodes.Contains(node)) // should always go to if branch
            {
                Nodes.Add(node);
            }
            else
            {
                for (int i = 0; i < Nodes.Count; i++)
                {
                    if (node.Number == Nodes[i].Number)
                    {
                        if (ReferenceEquals(node, Nodes[i]))
                        {
                            ;
                        }
                        else
                        {
                            ;
                        }
                    }
                }
            }
        }