/// <summary> /// Construct a neuron gene. /// </summary> /// <param name="type">The neuron type.</param> /// <param name="theActivationFunction">The activation function.</param> /// <param name="id">The neuron id.</param> /// <param name="innovationId">The innovation id.</param> public NEATNeuronGene(NEATNeuronType type, IActivationFunction theActivationFunction, long id, long innovationId) { NeuronType = type; InnovationId = innovationId; Id = id; ActivationFunction = theActivationFunction; }
public NEATNeuron(NEATNeuronType neuronType_0, long neuronID_1, double splitY_2, double splitX_3, double activationResponse_4) { this._inboundLinks = new List<NEATLink>(); this._outputboundLinks = new List<NEATLink>(); this._neuronType = neuronType_0; if ((((uint) neuronID_1) + ((uint) neuronID_1)) >= 0) { while (true) { this._neuronID = neuronID_1; this._splitY = splitY_2; this._splitX = splitX_3; this._activationResponse = activationResponse_4; this._posX = 0; if (((uint) splitX_3) <= uint.MaxValue) { this._posY = 0; if ((((uint) splitY_2) - ((uint) splitY_2)) <= uint.MaxValue) { break; } } } } if (0 == 0) { this._output = 0.0; this._sumActivation = 0.0; if ((((uint) neuronID_1) + ((uint) activationResponse_4)) <= uint.MaxValue) { } } }
public NEATInnovation(long fromNeuronID_0, long toNeuronID_1, NEATInnovationType innovationType_2, long innovationID) { if ((((uint) innovationID) + ((uint) fromNeuronID_0)) <= uint.MaxValue) { this.fromNeuronID = fromNeuronID_0; this.toNeuronID = toNeuronID_1; if (((uint) toNeuronID_1) > uint.MaxValue) { return; } goto Label_003B; } if (0 == 0) { goto Label_003B; } Label_0021: if ((((uint) fromNeuronID_0) + ((uint) fromNeuronID_0)) < 0) { goto Label_0052; } return; Label_003B: this.innovationType = innovationType_2; base.InnovationID = innovationID; this.neuronID = -1L; Label_0052: this.splitX = 0.0; this.splitY = 0.0; this.neuronType = NEATNeuronType.None; goto Label_0021; }
public NEATInnovation(long fromNeuronID_0, long toNeuronID_1, NEATInnovationType innovationType_2, long innovationID, NEATNeuronType neuronType_3, double x, double y) { goto Label_0057; Label_0023: this.innovationType = innovationType_2; base.InnovationID = innovationID; this.neuronType = neuronType_3; this.splitX = x; this.splitY = y; this.neuronID = 0L; if (0 == 0) { return; } if (-2147483648 != 0) { goto Label_0057; } Label_004C: this.fromNeuronID = fromNeuronID_0; this.toNeuronID = toNeuronID_1; goto Label_0023; Label_0057: if ((((uint) y) + ((uint) toNeuronID_1)) < 0) { goto Label_0023; } goto Label_004C; }
public static string NeuronTypeToString(NEATNeuronType t) { NEATNeuronType type = t; if (0 == 0) { switch (type) { case NEATNeuronType.Bias: return "b"; case NEATNeuronType.Hidden: return "h"; case NEATNeuronType.Input: goto Label_0005; case NEATNeuronType.None: return "n"; case NEATNeuronType.Output: return "o"; } return null; } Label_0005: return "i"; }
/// <summary> /// Construct a neuron gene. /// </summary> /// /// <param name="type">The type of neuron.</param> /// <param name="id">The id of this gene.</param> /// <param name="splitY_0">The split y.</param> /// <param name="splitX_1">The split x.</param> /// <param name="recurrent_2">True if this is a recurrent link.</param> /// <param name="act">The activation response.</param> public NEATNeuronGene(NEATNeuronType type, long id, double splitY_0, double splitX_1, bool recurrent_2, double act) { neuronType = type; Id = id; splitX = splitX_1; splitY = splitY_0; recurrent = recurrent_2; activationResponse = act; }
/// <summary> /// Construct a neuron gene. /// </summary> /// <param name="type">The type of neuron.</param> /// <param name="id">The id of this gene.</param> /// <param name="splitY">The split y.</param> /// <param name="splitX">The split x.</param> /// <param name="recurrent">True if this is a recurrent link.</param> /// <param name="act">The activation response.</param> public NEATNeuronGene(NEATNeuronType type, long id, double splitY, double splitX, bool recurrent, double act) { neuronType = type; this.Id = id; this.splitX = splitX; this.splitY = splitY; this.recurrent = recurrent; activationResponse = act; }
/// <summary> /// Copy another gene to this one. /// </summary> /// /// <param name="gene">The other gene.</param> public override void Copy(IGene gene) { var other = (NEATNeuronGene)gene; activationResponse = other.activationResponse; Id = other.Id; neuronType = other.neuronType; recurrent = other.recurrent; splitX = other.splitX; splitY = other.splitY; }
/// <summary> /// Construct an innovation. /// </summary> /// /// <param name="fromNeuronID_0">The from neuron.</param> /// <param name="toNeuronID_1">The two neuron.</param> /// <param name="innovationType_2">The innovation type.</param> /// <param name="innovationID">The innovation id.</param> public NEATInnovation(long fromNeuronID_0, long toNeuronID_1, NEATInnovationType innovationType_2, long innovationID) { fromNeuronID = fromNeuronID_0; toNeuronID = toNeuronID_1; innovationType = innovationType_2; InnovationID = innovationID; neuronID = -1; splitX = 0; splitY = 0; neuronType = NEATNeuronType.None; }
/// <summary> /// Construct an innovation. /// </summary> /// /// <param name="neuronGene">The neuron gene.</param> /// <param name="innovationID">The innovation id.</param> /// <param name="neuronID_0">The neuron id.</param> public NEATInnovation(NEATNeuronGene neuronGene, long innovationID, long neuronID_0) { neuronID = neuronID_0; InnovationID = innovationID; splitX = neuronGene.SplitX; splitY = neuronGene.SplitY; neuronType = neuronGene.NeuronType; innovationType = NEATInnovationType.NewNeuron; fromNeuronID = -1; toNeuronID = -1; }
/// <summary> /// Construct an innovation. /// </summary> /// <param name="fromNeuronID">The from neuron.</param> /// <param name="toNeuronID">The two neuron.</param> /// <param name="innovationType">The innovation type.</param> /// <param name="innovationID">The innovation id.</param> public NEATInnovation(long fromNeuronID, long toNeuronID, NEATInnovationType innovationType, long innovationID) { this.fromNeuronID = fromNeuronID; this.toNeuronID = toNeuronID; this.innovationType = innovationType; InnovationID = innovationID; neuronID = -1; splitX = 0; splitY = 0; neuronType = NEATNeuronType.None; }
/// <summary> /// Construct a NEAT neuron. /// </summary> /// <param name="neuronType">The type of neuron.</param> /// <param name="neuronID">The id of the neuron.</param> /// <param name="splitY">The split for y.</param> /// <param name="splitX">THe split for x.</param> /// <param name="activationResponse">The activation response.</param> public NEATNeuron(NEATNeuronType neuronType, long neuronID, double splitY, double splitX, double activationResponse) { this.neuronType = neuronType; this.neuronID = neuronID; this.splitY = splitY; this.splitX = splitX; this.activationResponse = activationResponse; posX = 0; posY = 0; output = 0; sumActivation = 0; }
/// <summary> /// Construct an innovation. /// </summary> /// /// <param name="fromNeuronID_0">The from neuron.</param> /// <param name="toNeuronID_1">The to neuron.</param> /// <param name="innovationType_2">The innovation type.</param> /// <param name="innovationID">The innovation id.</param> /// <param name="neuronType_3">The neuron type.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">THe y coordinate.</param> public NEATInnovation(long fromNeuronID_0, long toNeuronID_1, NEATInnovationType innovationType_2, long innovationID, NEATNeuronType neuronType_3, double x, double y) { fromNeuronID = fromNeuronID_0; toNeuronID = toNeuronID_1; innovationType = innovationType_2; InnovationID = innovationID; neuronType = neuronType_3; splitX = x; splitY = y; neuronID = 0; }
/// <summary> /// Construct an innovation. /// </summary> /// <param name="fromNeuronID">The from neuron.</param> /// <param name="toNeuronID">The to neuron.</param> /// <param name="innovationType">The innovation type.</param> /// <param name="innovationID">The innovation id.</param> /// <param name="neuronType">The neuron type.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> public NEATInnovation(long fromNeuronID, long toNeuronID, NEATInnovationType innovationType, long innovationID, NEATNeuronType neuronType, double x, double y) { this.fromNeuronID = fromNeuronID; this.toNeuronID = toNeuronID; this.innovationType = innovationType; InnovationID = innovationID; this.neuronType = neuronType; splitX = x; splitY = y; neuronID = 0; }
/// <summary> /// Create a new innovation. /// </summary> /// <param name="from">The from neuron.</param> /// <param name="to">The to neuron.</param> /// <param name="innovationType">The innovation type.</param> /// <param name="neuronType">The neuron type.</param> /// <param name="x">The x-coordinate.</param> /// <param name="y">The y-coordinate.</param> /// <returns>The new innovation.</returns> public long CreateNewInnovation(long from, long to, NEATInnovationType innovationType, NEATNeuronType neuronType, double x, double y) { NEATInnovation newInnovation = new NEATInnovation(from, to, innovationType, population.AssignInnovationID(), neuronType, x, y); if (innovationType == NEATInnovationType.NewNeuron) { newInnovation.NeuronID = AssignNeuronID(); } Innovations.Add(newInnovation); return(this.nextNeuronID - 1); // ??????? should it be innov? }
/// <summary> /// Construct a NEAT neuron. /// </summary> /// /// <param name="neuronType_0">The type of neuron.</param> /// <param name="neuronID_1">The id of the neuron.</param> /// <param name="splitY_2">The split for y.</param> /// <param name="splitX_3">THe split for x.</param> /// <param name="activationResponse_4">The activation response.</param> public NEATNeuron(NEATNeuronType neuronType_0, long neuronID_1, double splitY_2, double splitX_3, double activationResponse_4) { _inboundLinks = new List <NEATLink>(); _outputboundLinks = new List <NEATLink>(); _neuronType = neuronType_0; _neuronID = neuronID_1; _splitY = splitY_2; _splitX = splitX_3; _activationResponse = activationResponse_4; _posX = 0; _posY = 0; _output = 0; _sumActivation = 0; }
public NEATInnovation(NEATNeuronGene neuronGene, long innovationID, long neuronID_0) { if (8 != 0) { this.neuronID = neuronID_0; base.InnovationID = innovationID; this.splitX = neuronGene.SplitX; if (0xff == 0) { return; } this.splitY = neuronGene.SplitY; this.neuronType = neuronGene.NeuronType; this.innovationType = NEATInnovationType.NewNeuron; } this.fromNeuronID = -1L; this.toNeuronID = -1L; }
public NEATNeuronGene(NEATNeuronType type, long id, double splitY_0, double splitX_1, bool recurrent_2, double act) { while (true) { this.neuronType = type; if (3 != 0) { base.Id = id; this.splitX = splitX_1; this.splitY = splitY_0; this.recurrent = recurrent_2; this.activationResponse = act; if ((((uint) act) - ((uint) splitX_1)) >= 0) { return; } } } }
/// <summary> /// Convert NEAT neuron type to string. /// </summary> /// <param name="t">The neuron type.</param> /// <returns>The string of the specified neuron type.</returns> public static String NeuronType2String(NEATNeuronType t) { switch (t) { case NEATNeuronType.Input: return("I"); case NEATNeuronType.Bias: return("B"); case NEATNeuronType.Hidden: return("H"); case NEATNeuronType.Output: return("O"); case NEATNeuronType.None: return("N"); default: return(null); } }
/// <summary> /// Convert the neuron type to a string. /// </summary> /// <param name="t">The neuron type.</param> /// <returns>The string.</returns> public static String NeuronTypeToString(NEATNeuronType t) { switch (t) { case NEATNeuronType.Bias: return("b"); case NEATNeuronType.Hidden: return("h"); case NEATNeuronType.Input: return("i"); case NEATNeuronType.None: return("n"); case NEATNeuronType.Output: return("o"); default: return(null); } }
public override void Copy(IGene gene) { NEATNeuronGene gene2 = (NEATNeuronGene) gene; if (0 == 0) { this.activationResponse = gene2.activationResponse; base.Id = gene2.Id; if (0 == 0) { this.neuronType = gene2.neuronType; this.recurrent = gene2.recurrent; if (0 == 0) { goto Label_000A; } } return; } Label_000A: this.splitX = gene2.splitX; this.splitY = gene2.splitY; }
/// <summary> /// Read the object. /// </summary> /// <param name="mask0">The stream to read from.</param> /// <returns>The loaded object.</returns> public virtual Object Read(Stream mask0) { var result = new NEATNetwork(); var ins0 = new EncogReadHelper(mask0); EncogFileSection section; IDictionary <Int32, NEATNeuron> neuronMap = new Dictionary <Int32, NEATNeuron>(); while ((section = ins0.ReadNextSection()) != null) { if (section.SectionName.Equals("NEAT") && section.SubSectionName.Equals("PARAMS")) { IDictionary <String, String> paras = section.ParseParams(); foreach (String key in paras.Keys) { result.Properties.Add(key, paras[key]); } } if (section.SectionName.Equals("NEAT") && section.SubSectionName.Equals("NETWORK")) { IDictionary <String, String> p = section.ParseParams(); result.InputCount = EncogFileSection.ParseInt(p, PersistConst.InputCount); result.OutputCount = EncogFileSection.ParseInt(p, PersistConst.OutputCount); result.ActivationFunction = EncogFileSection .ParseActivationFunction(p, PersistConst.ActivationFunction); result.OutputActivationFunction = EncogFileSection .ParseActivationFunction(p, NEATPopulation.PropertyOutputActivation); result.NetworkDepth = EncogFileSection.ParseInt(p, PersistConst.Depth); result.Snapshot = EncogFileSection.ParseBoolean(p, PersistConst.Snapshot); } else if (section.SectionName.Equals("NEAT") && section.SubSectionName.Equals("NEURONS")) { foreach (String line in section.Lines) { IList <String> cols = EncogFileSection.SplitColumns(line); long neuronID = Int32.Parse(cols[0]); NEATNeuronType neuronType = PersistNEATPopulation .StringToNeuronType(cols[1]); double activationResponse = CSVFormat.EgFormat .Parse(cols[2]); double splitY = CSVFormat.EgFormat .Parse(cols[3]); double splitX = CSVFormat.EgFormat .Parse(cols[4]); var neatNeuron = new NEATNeuron(neuronType, neuronID, splitY, splitX, activationResponse); result.Neurons.Add(neatNeuron); neuronMap[((int)neuronID)] = (neatNeuron); } } else if (section.SectionName.Equals("NEAT") && section.SubSectionName.Equals("LINKS")) { foreach (String line in section.Lines) { IList <String> cols = EncogFileSection.SplitColumns(line); int fromID = Int32.Parse(cols[0]); int toID = Int32.Parse(cols[1]); bool recurrent = Int32.Parse(cols[2]) > 0; double weight = CSVFormat.EgFormat.Parse(cols[3]); NEATNeuron fromNeuron = (neuronMap[fromID]); NEATNeuron toNeuron = (neuronMap[toID]); var neatLink = new NEATLink(weight, fromNeuron, toNeuron, recurrent); fromNeuron.OutputboundLinks.Add(neatLink); toNeuron.InboundLinks.Add(neatLink); } } } return(result); }
/// <summary> /// Copy another gene to this one. /// </summary> /// <param name="gene">The other gene.</param> public void Copy(NEATNeuronGene gene) { NEATNeuronGene other = gene; Id = other.Id; NeuronType = other.NeuronType; ActivationFunction = other.ActivationFunction; InnovationId = other.InnovationId; }
/// <summary> /// Construct a gene. /// </summary> /// /// <param name="type">The type of neuron.</param> /// <param name="id">The id of this gene.</param> /// <param name="splitY_0">The split y.</param> /// <param name="splitX_1">The split x.</param> public NEATNeuronGene(NEATNeuronType type, long id, double splitY_0, double splitX_1) : this(type, id, splitY_0, splitX_1, false, 1.0d) { }
/// <summary> /// Copy another gene to this one. /// </summary> /// /// <param name="gene">The other gene.</param> public override void Copy(IGene gene) { var other = (NEATNeuronGene) gene; activationResponse = other.activationResponse; Id = other.Id; neuronType = other.neuronType; recurrent = other.recurrent; splitX = other.splitX; splitY = other.splitY; }
/// <summary> /// Construct a gene. /// </summary> /// <param name="type">The type of neuron.</param> /// <param name="id">The id of this gene.</param> /// <param name="splitY">The split y.</param> /// <param name="splitX">The split x.</param> public NEATNeuronGene(NEATNeuronType type, long id, double splitY, double splitX) : this(type, id, splitY, splitX, false, 1.0) { }
/// <summary> /// Convert a NEATNeuronType enum to a string. /// </summary> /// <param name="t">The type.</param> /// <returns>The string type.</returns> public static String NeuronTypeToString(NEATNeuronType t) { switch (t) { case NEATNeuronType.Bias: return "b"; case NEATNeuronType.Hidden: return "h"; case NEATNeuronType.Input: return "i"; case NEATNeuronType.None: return "n"; case NEATNeuronType.Output: return "o"; default: return null; } }
/// <summary> /// Create a new innovation. /// </summary> /// <param name="from">The from neuron.</param> /// <param name="to">The to neuron.</param> /// <param name="innovationType">The innovation type.</param> /// <param name="neuronType">The neuron type.</param> /// <param name="x">The x-coordinate.</param> /// <param name="y">The y-coordinate.</param> /// <returns>The new innovation.</returns> public long CreateNewInnovation(long from, long to, NEATInnovationType innovationType, NEATNeuronType neuronType, double x, double y) { NEATInnovation newInnovation = new NEATInnovation(from, to, innovationType, population.AssignInnovationID(), neuronType, x, y); if (innovationType == NEATInnovationType.NewNeuron) { newInnovation.NeuronID = AssignNeuronID(); } Innovations.Add(newInnovation); return (this.nextNeuronID - 1); // ??????? should it be innov? }
public long CreateNewInnovation(long from, long to, NEATInnovationType innovationType, NEATNeuronType neuronType, double x, double y) { NEATInnovation innovation = new NEATInnovation(from, to, innovationType, this.population.AssignInnovationID(), neuronType, x, y); if (0 == 0) { } while (innovationType == NEATInnovationType.NewNeuron) { innovation.NeuronID = this.AssignNeuronID(); break; } base.Add(innovation); return (this.nextNeuronID - 1L); }
/// <summary> /// Construct a NEAT neuron. /// </summary> /// /// <param name="neuronType_0">The type of neuron.</param> /// <param name="neuronID_1">The id of the neuron.</param> /// <param name="splitY_2">The split for y.</param> /// <param name="splitX_3">THe split for x.</param> /// <param name="activationResponse_4">The activation response.</param> public NEATNeuron(NEATNeuronType neuronType_0, long neuronID_1, double splitY_2, double splitX_3, double activationResponse_4) { _inboundLinks = new List<NEATLink>(); _outputboundLinks = new List<NEATLink>(); _neuronType = neuronType_0; _neuronID = neuronID_1; _splitY = splitY_2; _splitX = splitX_3; _activationResponse = activationResponse_4; _posX = 0; _posY = 0; _output = 0; _sumActivation = 0; }
/// <summary> /// Convert NEAT neuron type to string. /// </summary> /// <param name="t">The neuron type.</param> /// <returns>The string of the specified neuron type.</returns> public static String NeuronType2String(NEATNeuronType t) { switch (t) { case NEATNeuronType.Input: return "I"; case NEATNeuronType.Bias: return "B"; case NEATNeuronType.Hidden: return "H"; case NEATNeuronType.Output: return "O"; case NEATNeuronType.None: return "N"; default: return null; } }