/// <summary> /// Create a Genome using the intergalactic neat /// </summary> public ChaoticSeer() { SURVIVAL_THRESHOLD = 0.02f; AGE_THRESHOLD = 60; //Replace with random that averages to 60 REPRODUCE_START_THRESHOLD = 12; // Replace with random that averages to 15 REPRODUCE_END_THRESHOLD = 50; // Replace with random that averages to 45 EVOLVE_START_THRESHOLD = 0; EVOLVE_END_THRESHOLD = 40; // replace with random that averages to 45 Connections = new GeneHashSet <ConnectionGene>(); Nodes = new GeneHashSet <NodeGene>(); _mutation = new Mutation.MutationST(); Fitness = 0; Year = 0; Day = 0; int _InOut = Sg.Neat.InputSize + Sg.Neat.OutputSize; if (_InOut > NeatCNS.MAX_NODES) { throw new NotSupportedException("nodes reached its theoretical max limit"); } for (int i = 0; i < _InOut; i++) { Nodes.Add(Sg.Neat.AddNode(i + 1)); } }
} //Motor #endregion NeatCNS(int maxNodes) { //MAX_NODES = (int)Math.Pow(2, 20); // 1M max nodes T_MAX_NODES = maxNodes; Connections = new Dictionary <ConnectionGene, ConnectionGene>(); Nodes = new GeneHashSet <NodeGene>(); C1 = 1; C2 = 1; C3 = 1; }
/// <summary> /// Create a batch of species filled with Genomes using the intergalactic neat /// </summary> /// <param name="maxPopulation"></param> public Tribe(int maxPopulation) { MAX_POPULATION = maxPopulation; Species = new GeneHashSet <ChaoticSeer>(); for (int i = 0; i < maxPopulation; i++) { Species.Add(new ChaoticSeer() { Identity = i }); } }
/// <summary> /// Create a batch of species filled with Genomes initializing the intergalactic neat /// </summary> /// <param name="inputSize"></param> /// <param name="outputSize"></param> /// <param name="maxPopulation">Target population</param> /// <param name="maxNodes">Target nodes</param> public Tribe(int inputSize, int outputSize, int maxPopulation, int maxNodes = 10) { MAX_POPULATION = maxPopulation; Sg.Neat = new NeatCNS(inputSize, outputSize, maxNodes); Species = new GeneHashSet <ChaoticSeer>(); for (int i = 0; i < maxPopulation; i++) { Species.Add(new ChaoticSeer() { Identity = i }); } }
public FPropagateST(ChaoticSeer seer) { InputNodes = new List <CalcNode>(); HiddenNodes = new List <CalcNode>(); OutputNodes = new List <CalcNode>(); GeneHashSet <NodeGene> _nodes = seer.Nodes; GeneHashSet <ConnectionGene> _cons = seer.Connections; Dictionary <int, CalcNode> _nodeHashMap = new Dictionary <int, CalcNode>(); foreach (NodeGene item in _nodes.Data) { CalcNode node = new CalcNode(item.X); _nodeHashMap.Add(item.InnovationNumber, node); if (item.X <= 0.1f) { InputNodes.Add(node); } else if (item.X >= 0.9f) { OutputNodes.Add(node); } else { HiddenNodes.Add(node); } } HiddenNodes.Sort(); //This thing is working correct foreach (ConnectionGene item in _cons.Data) { NodeGene from = item.From; NodeGene to = item.To; CalcNode node_from = _nodeHashMap[from.InnovationNumber]; CalcNode node_to = _nodeHashMap[to.InnovationNumber]; CalcConnection con = new CalcConnection(node_from, node_to) { Weight = item.Weight, IsEnabled = item.IsEnabled }; node_to.Connections.Add(con); } }