/// <summary> /// Used from regulation modules to add a new local output neuron connected /// to the regulatory neuron of the module we are adding. Also creates /// connections from local inputs to the new local output. /// </summary> public void AskAddModuleToRegModule(UIvariables uiVar, newLink localOutInfo) { _ea.GenomeList[0].GenomeFactory.AddModuleToRegModule( _ea.GenomeList, baseFilesPath, experiment_name, uiVar, localOutInfo); UpdateChampion(); SimpleSavePopulation(); }
/// <summary> /// Make this the active module if it is not already. /// If the module has basic regulation it is also (provisionally) made /// the only active module (children left normal). This is so during evolution /// only the behaviour of this module is shown, with no interference. /// </summary> protected void EvolveContinue(List <int> childrenId) { if (!isActive) { // This will be a new evolutionary process, so we need to set this // module as the active module in the genome! uiManager.SetModuleActive(moduleId); } // If this module uses basic regulation, then we set it as the only // active module! (its children will also remain active!) // // USE WITH ADVANCED REGULATION IS NOT FULLY SUPPORTED YET: USE WITH // CAUTION! newLink newRegulation = new newLink(); // Regulation from bias newRegulation.otherNeuron = 0; // With weight 1 newRegulation.weight = 1.0; // Takes the ID following that of the regulatory neuron newRegulation.id = regulatoryId + 1; uiManager.MakeOnlyActiveMod(moduleId, newRegulation, childrenId); uiManager.LaunchEvolution(); }
/// <summary> /// Adds a new connection to the regulation list (from a given input, with /// a desired weight). As of this version this method does not work /// with other inputs (only global input neurons not, for example, /// local output neurons as regulation sources). /// </summary> public void AddInputToReg(int newInput, double newWeight) { newLink auxLink = new newLink(); // Bias (0) will take id = reg + 1, input 1 will take reg + 2 and so on. auxLink.id = regulatoryId + (uint)newInput + 1; // For basic regulation, source neuron Id = source neuron Index // (if this changes, we will need to be sure to find the Id first!) auxLink.otherNeuron = (uint)newInput; auxLink.weight = newWeight; regulatoryInputList.Add(auxLink); }
/// <summary> /// Sets a new weight for all output connections. /// </summary> public void newOutputWeightBasic(double newWeight) { for (int i = 0; i < localOutputList.Count; ++i) { newLink auxLink = localOutputList[i]; auxLink.weight = newWeight; localOutputList[i] = auxLink; } // Returns the new values back to UImanager uiManager.GetNewOutputConnectionList(moduleId, localOutputList); // We record this action: uiManager.WriteToRecord("New weights for " + moduleId + " now: " + newWeight.ToString()); }
/// <summary> /// Creates the new element for the local output and adds it to the list. /// The new local output will link with the regulatory neuron of the other /// module. This is notified to UImanager, which invokes EspGenomeFactory /// so this connection is actually created in the genome. /// </summary> void UpdateLocalOutAndNotify() { newLink newLocalOut = new newLink(); newLocalOut.otherNeuron = otherModule.GetComponent <ModuleController>().RegulatoryId; newLocalOut.weight = 1.0; uint lastLocalOutId; int lastLocalOutindex; if (uiManager.Genome.NeuronGeneList.FindLastLocalOut(moduleId, out lastLocalOutindex)) { lastLocalOutId = uiManager.Genome.NeuronGeneList[lastLocalOutindex].Id; if (modulesContained > 1) { // Our new local output neuron will take the index of the last // + 2, and + 1 for the protected connection, which comes first newLocalOut.id = lastLocalOutId + 1; } else { // If modulesContained == 1, this is the first module we are adding, // and the ID for the connection is the ID of the local output // neuron, - 1. newLocalOut.id = lastLocalOutId - 1; } // Call add uiManager.AskAddModuleToRegModule(newLocalOut); // Before leaving we add the information of this connection to the // input-to-regulation list of the other module. Note that this // connection (coming from a local output instead of an input or // bias neuron) will be disregarded in factory, but it can be very // useful for the interface. // We need to change the "otherNeuron" field, because in the other // module we need the source of the connection, not the target! newLocalOut.otherNeuron = newLocalOut.id + 1; otherModule.GetComponent <ModuleController>(). RegulatoryInputList.Add(newLocalOut); } else { // TODO: Notify error! Debug.Log("Could not find local out neuron. RegModuleController."); } }