private static void Play() { var neatGenomeFactory = new NeatGenomeFactory(NeatConsts.ViewX * NeatConsts.ViewY * NeatConsts.typeIds.Count, 1); var activationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(1); var genomeDecoder = new NeatGenomeDecoder(activationScheme); XmlReader xr; while (true) { try { xr = XmlReader.Create($"{NeatConsts.experimentName}/best.xml"); break; } catch (Exception) { } } var genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, neatGenomeFactory)[0]; var phenome = genomeDecoder.Decode(genome); using var game = new Game(true); var brain = new BlackBoxBrain(phenome, game); while (!game.hasEnded) { brain.Step(); Thread.Sleep(200); } }
/// <summary> /// Initialize the experiment with some optional XML configuration data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _trialsPerEvaluation = XmlUtils.GetValueAsInt(xmlConfig, "TrialsPerEvaluation"); _gridSize = XmlUtils.GetValueAsInt(xmlConfig, "GridSize"); _preyInitMoves = XmlUtils.GetValueAsInt(xmlConfig, "PreyInitMoves"); _preySpeed = XmlUtils.GetValueAsDouble(xmlConfig, "PreySpeed"); _sensorRange = XmlUtils.GetValueAsDouble(xmlConfig, "SensorRange"); _maxTimesteps = XmlUtils.GetValueAsInt(xmlConfig, "MaxTimesteps"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _eaParams.ElitismProportion = 0.66; _eaParams.SelectionProportion = 0.66; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.ActivationFn = LeakyReLU.__DefaultInstance; }
/// <summary> /// This is inspired by ExperimentUtils.CreateActivationScheme, but can't be put there, because NeatConfigInfo_Activation isn't /// defined that low /// </summary> private static NetworkActivationScheme GetActivationScheme(ExperimentInitArgs_Activation scheme) { if (scheme == null) { throw new ArgumentNullException("scheme"); } else if (scheme is ExperimentInitArgs_Activation_Acyclic) { return(NetworkActivationScheme.CreateAcyclicScheme()); } else if (scheme is ExperimentInitArgs_Activation_CyclicFixedTimesteps) { ExperimentInitArgs_Activation_CyclicFixedTimesteps cast = (ExperimentInitArgs_Activation_CyclicFixedTimesteps)scheme; return(NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(cast.TimestepsPerActivation, cast.FastFlag)); } else if (scheme is ExperimentInitArgs_Activation_CyclicRelaxing) { ExperimentInitArgs_Activation_CyclicRelaxing cast = (ExperimentInitArgs_Activation_CyclicRelaxing)scheme; return(NetworkActivationScheme.CreateCyclicRelaxingActivationScheme(cast.SignalDeltaThreshold, cast.MaxTimesteps, cast.FastFlag)); } else { throw new ArgumentException("Unknown scheme type: " + scheme.GetType().ToString()); } }
/// <summary> /// Evolves the requisite number of agents who satisfy the MC of the given maze. /// </summary> /// <param name="genomeFactory">The agent genome factory.</param> /// <param name="seedAgentList">The seed population of agents.</param> /// <param name="mazeStructure">The maze structure on which agents are to be evaluated.</param> /// <param name="maxInitializationEvals"> /// The maximum number of evaluations to run algorithm before restarting with new, /// randomly generated population. /// </param> /// <param name="activationScheme">The activation scheme for the NEAT agent networks (e.g. cyclic or acyclic).</param> /// <param name="parallelOptions">Synchronous/Asynchronous execution settings.</param> /// <returns>The list of viable agent genomes.</returns> public IEnumerable <NeatGenome> EvolveViableAgents(IGenomeFactory <NeatGenome> genomeFactory, List <NeatGenome> seedAgentList, MazeStructure mazeStructure, uint?maxInitializationEvals, NetworkActivationScheme activationScheme, ParallelOptions parallelOptions) { List <NeatGenome> viableMazeAgents; uint restartCount = 0; ulong initializationEvaluations; do { // Instantiate the internal initialization algorithm InitializeAlgorithm(parallelOptions, seedAgentList.ToList(), genomeFactory, mazeStructure, new NeatGenomeDecoder(activationScheme), 0); // Run the initialization algorithm until the requested number of viable seed genomes are found viableMazeAgents = RunEvolution(out initializationEvaluations, maxInitializationEvals, restartCount); restartCount++; // Repeat if maximum allotted evaluations is exceeded } while (maxInitializationEvals != null && viableMazeAgents == null && initializationEvaluations > maxInitializationEvals); return(viableMazeAgents); }
public virtual void Initialize(string name, XmlElement xmlConfig) { _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "DefaultComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; DefaultComplexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy( _complexityRegulationStr, _complexityThreshold); DefaultSpeciationStrategy = new KMeansClusteringStrategy <NeatGenome>(new ManhattanDistanceMetric(1.0, 0.0, 10.0)); DefaultNeatEvolutionAlgorithm = new NeatEvolutionAlgorithm <NeatGenome>( NeatEvolutionAlgorithmParameters, DefaultSpeciationStrategy, DefaultComplexityRegulationStrategy); }
/// <summary> /// Initialize the experiment with some optional XML configutation data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { _name = name; _description = "Just a test experiment class"; // Dont use xml, just hard code the values for now _populationSize = 50; _specieCount = 5; // PicBreeder appears to use acyclic networks, so we will do the same. // Cyclic ("recurrent") networks seem better for realtime reactive controllers, e.g. predator-prey, where the recurrent connections allow for memory of past events _activationScheme = NetworkActivationScheme.CreateAcyclicScheme(); // Next two values just seem to be commen. // Relative just means that limit of complexification is relative to the last simplification process (so it can continue to grow) // Alternative is "Absolute", which means, with a threshold of 10, network wont ever be more complex than 10 connections _complexityRegulationStr = "Absolute"; _complexityThreshold = 50; //_parallelOptions = new ParallelOptions(); // Param constructors set defaul param values, a lot of experiments just leave them as default _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; }
public IEnumerator Start() { Debug.Assert(_populationSize > 5); Debug.Log($"Main thread is {Thread.CurrentThread.ManagedThreadId}"); Application.runInBackground = true; _activationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(2, true); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.ElitismProportion = _elitismProportion; _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.AddConnectionMutationProbability = _AddConnectionMutationProbability; _neatGenomeParams.DeleteConnectionMutationProbability = _DeleteConnectionMutationProbability; _neatGenomeParams.AddNodeMutationProbability = _AddNodeMutationProbability; _neatGenomeParams.ConnectionWeightMutationProbability = _ConnectionWeightMutationProbability; _neatGenomeParams.InitialInterconnectionsProportion = _InitialInterconnectionsProportion; _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; Debug.Log("Creating evaluator"); yield return(new WaitForSeconds(0.1f)); _evaluator = CreateEvaluator(); Debug.Log("Creating algorithm"); yield return(new WaitForSeconds(0.1f)); _ea = CreateEvolutionAlgorithm(_evaluator, _populationSize); _ea.UpdateEvent += _ea_UpdateEvent; }
public Experiment() { this.InputCount = 36; this.OutputCount = 3; this.eaParams = new NeatEvolutionAlgorithmParameters(); this.eaParams.SpecieCount = 200; // default: 10 this.eaParams.ElitismProportion = 0.05; // default: 0.2 this.eaParams.SelectionProportion = 0.15; // default: 0.2 this.eaParams.OffspringAsexualProportion = 0.7; // default: 0.5 this.eaParams.OffspringSexualProportion = 0.3; // default: 0.5 this.eaParams.InterspeciesMatingProportion = 0.01; // default: 0.01 this.neatGenomeParams = new NeatGenomeParameters(); this.neatGenomeParams.ConnectionWeightRange = 3.0; // default: 5 this.neatGenomeParams.ConnectionWeightMutationProbability = 0.95; // default: 0.94; this.neatGenomeParams.AddNodeMutationProbability = 0.01; // default: 0.01; this.neatGenomeParams.AddConnectionMutationProbability = 0.075; // default: 0.025; this.neatGenomeParams.DeleteConnectionMutationProbability = 0.075; // default: 0.025; this.parallelOptions = new ParallelOptions(); //this.parallelOptions.MaxDegreeOfParallelism = 8; this.activationScheme = NetworkActivationScheme.CreateAcyclicScheme(); //NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(1); this.neatGenomeParams.FeedforwardOnly = this.activationScheme.AcyclicNetwork; }
/// <summary> /// Initialize the experiment with some optional XML configuration data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _eaParams.SelectionProportion = 0.5; _eaParams.ElitismProportion = 0.5; _eaParams.OffspringAsexualProportion = 0.95; _eaParams.OffspringSexualProportion = 0.05; _eaParams.InterspeciesMatingProportion = 0.00; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.AddConnectionMutationProbability = 0.1; _neatGenomeParams.AddNodeMutationProbability = 0.01; _neatGenomeParams.ConnectionWeightMutationProbability = 0.89; _neatGenomeParams.InitialInterconnectionsProportion = 0.05; }
/// <summary> /// Create a network activation scheme from the scheme setting in the provided config XML. /// </summary> /// <returns></returns> public static NetworkActivationScheme CreateActivationScheme(XmlElement xmlConfig, string activationElemName) { // Get root activation element. XmlNodeList nodeList = xmlConfig.GetElementsByTagName(activationElemName, ""); if (nodeList.Count != 1) { throw new ArgumentException("Missing or invalid activation XML config setting."); } XmlElement xmlActivation = nodeList[0] as XmlElement; string schemeStr = XmlUtils.TryGetValueAsString(xmlActivation, "Scheme"); switch (schemeStr) { case "Acyclic": return(NetworkActivationScheme.CreateAcyclicScheme()); case "CyclicFixedIters": int iters = XmlUtils.GetValueAsInt(xmlActivation, "Iters"); return(NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(iters)); case "CyclicRelax": double deltaThreshold = XmlUtils.GetValueAsInt(xmlActivation, "Threshold"); int maxIters = XmlUtils.GetValueAsInt(xmlActivation, "MaxIters"); return(NetworkActivationScheme.CreateCyclicRelaxingActivationScheme(deltaThreshold, maxIters)); } throw new ArgumentException(string.Format("Invalid or missing ActivationScheme XML config setting [{0}]", schemeStr)); }
private void Initialize_private(string name, ExperimentInitArgs args) { Name = name; Description = args.Description; _inputCount = args.InputCount; _outputCount = args.OutputCount; DefaultPopulationSize = args.PopulationSize; IsHyperNEAT = args.IsHyperNEAT; if (args.IsHyperNEAT) { _activationSchemeCppn = GetActivationScheme_CPPN(); } _activationDefinition = args.Activation; _activationScheme = GetActivationScheme(args.Activation); _complexityRegulationStr = args.Complexity_RegulationStrategy?.ToString(); _complexityThreshold = args.Complexity_Threshold; _parallelOptions = args.MaxDegreeOfParallelism == null ? new ParallelOptions() : new ParallelOptions { MaxDegreeOfParallelism = args.MaxDegreeOfParallelism.Value }; NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters(); NeatEvolutionAlgorithmParameters.SpecieCount = args.SpeciesCount; }
/// <summary> /// Method that determines which substrate instance creation routine to use. /// </summary> private CreateSubstrateNetwork GetCreateSubstrateNetworkMethod(NetworkActivationScheme activationScheme) { if (activationScheme.FastFlag) { return(CreateSubstrateNetwork_FastCyclicNetwork); } return(CreateSubstrateNetwork_CyclicNetwork); }
/// <summary> /// Method that determines which CPPN decode routine to use. /// </summary> private DecodeCppnGenome GetDecodeCppnMethod(NetworkActivationScheme activationScheme) { if (activationScheme.FastFlag) { return(DecodeToFastCyclicNetwork); } return(DecodeToCyclicNetwork); }
NeatEvolutionAlgorithm <NeatGenome> CreateEvolutionAlgorithm(bool load) { // Create a genome2 factory with our neat genome2 parameters object and the appropriate number of input and output neuron genes. var genomeFactory = new NeatGenomeFactory(TetrisEvaluator.NumInputs, TetrisEvaluator.NumOutputs); // Create an initial population of randomly generated genomes. List <NeatGenome> genomeList = null; if (load) { try { using (var reader = XmlReader.Create("SavedProgress.xml")) genomeList = NeatGenomeXmlIO.ReadCompleteGenomeList(reader, true, genomeFactory); Console.WriteLine("Loaded network!"); } catch { load = false; } } if (!load) { genomeList = genomeFactory.CreateGenomeList(150, 0); } var parallelOpts = new ParallelOptions() { MaxDegreeOfParallelism = -1 }; // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. var distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); var speciationStrategy = new ParallelKMeansClusteringStrategy <NeatGenome>(distanceMetric, parallelOpts); // Create the evolution algorithm. var ea = new NeatEvolutionAlgorithm <NeatGenome>(new NeatEvolutionAlgorithmParameters { SpecieCount = 10 }, speciationStrategy, new DefaultComplexityRegulationStrategy(ComplexityCeilingType.Absolute, 50)); // Create genome2 decoder. var genomeDecoder = new NeatGenomeDecoder(NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(2)); // Create a genome2 list evaluator. This packages up the genome2 decoder with the genome2 evaluator. IGenomeListEvaluator <NeatGenome> genomeListEvaluator = new ParallelGenomeListEvaluator <NeatGenome, IBlackBox>(genomeDecoder, tetrisEvaluator, parallelOpts); // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determiend by examining each genome2's evaluation info object. //if (!EvaluateParents) //genomeListEvaluator = new SelectiveGenomeListEvaluator<NeatGenome>(genomeListEvaluator, SelectiveGenomeListEvaluator<NeatGenome>.CreatePredicate_OnceOnly()); ea.UpdateEvent += Ea_UpdateEvent; // Initialize the evolution algorithm. ea.Initialize(genomeListEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return(ea); }
/// <summary> /// Initialize the experiment with some optional XML configutation data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _guesses = XmlUtils.GetValueAsInt(xmlConfig, "Guesses"); Hashed = XmlUtils.TryGetValueAsBool(xmlConfig, "Hashed").HasValue ? XmlUtils.GetValueAsBool(xmlConfig, "Hashed") : false; ValidationGuesses = XmlUtils.GetValueAsInt(xmlConfig, "ValidationGuesses"); // Load the passwords from file string pwdfile = XmlUtils.TryGetValueAsString(xmlConfig, "ValidationPasswordFile"); if (pwdfile != null) { Console.Write("Loading passwords from [{0}]...", pwdfile); if (_passwords == null || _passwords.Count == 0) { int?pwLength = XmlUtils.TryGetValueAsInt(xmlConfig, "PasswordLength"); if (pwLength.HasValue) { Console.Write("Filtering to {0}-character passwords...", pwLength.Value); } _passwords = PasswordUtil.LoadPasswords(pwdfile, pwLength); } else { Console.WriteLine("WARNING: Not loading passwords for experiment (already set)"); } } else { Console.WriteLine("WARNING: Not loading passwords for experiment (not provided in config file)"); } _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = false; _neatGenomeParams.AddNodeMutationProbability = 0.03; _neatGenomeParams.AddConnectionMutationProbability = 0.05; // TODO: Load states from XML config file // Generates all the valid states in the MC using all viable ASCII characters var stateList = new List <string>(); for (uint i = 32; i < 127; i++) { stateList.Add(((char)i).ToString()); } stateList.Add(null); _states = stateList.ToArray(); _activationFnLibrary = MarkovActivationFunctionLibrary.CreateLibraryMc(_states); }
/// <summary> /// Create an activation scheme for cyclic networks. /// </summary> /// <param name="cyclesPerActivation">The number of activation cycles to perform per overall activation of /// the cyclic network.</param> /// <returns>A new instance of <see cref="NetworkActivationScheme"/>.</returns> public static NetworkActivationScheme CreateCyclicScheme(int cyclesPerActivation) { NetworkActivationScheme scheme = new NetworkActivationScheme { _acyclicNetwork = false, _cyclesPerActivation = cyclesPerActivation }; return(scheme); }
bool CheckActivationScheme(NetworkActivationScheme scheme) { if (!scheme.Esp) { System.Console.WriteLine("\nOnly EspCyclic activation scheme is compatible " + "with this version.\n"); return(false); } return(true); }
/// <summary> /// Constructs with the provided substrate, CPPN activation scheme and substrate /// network activation scheme. /// </summary> public HyperNeatDecoder(ISubstrate substrate, NetworkActivationScheme activationSchemeCppn, NetworkActivationScheme activationSchemeSubstrate) { _substrate = substrate; _activationSchemeCppn = activationSchemeCppn; _activationSchemeSubstrate = activationSchemeSubstrate; _decodeCppnMethod = GetDecodeCppnMethod(_activationSchemeCppn); _createSubstrateNetworkMethod = GetCreateSubstrateNetworkMethod(activationSchemeSubstrate); }
/// <summary> /// Create an activation scheme with a fixed number of activation timesteps (suitable for cyclic networks only). /// 'fastFlag' indicates if a fast network implementation should be used. /// </summary> public static NetworkActivationScheme CreateCyclicFixedTimestepsScheme(int timestepsPerActivation, bool fastFlag) { NetworkActivationScheme scheme = new NetworkActivationScheme(); scheme._acyclicNetwork = false; scheme._timestepsPerActivation = timestepsPerActivation; scheme._relaxingActivation = false; scheme._fastFlag = fastFlag; return(scheme); }
/// <summary> /// Initialize the experiment with some optional XML configutation data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.OffspringAsexualProportion = 1.0; _eaParams.OffspringSexualProportion = 0.0; _eaParams.SpecieCount = _specieCount; _eaParams.InterspeciesMatingProportion = 0.0; _neatGenomeParams = new NeatGenomeParameters(); if (name == "Small mutation") { // Small mutation parameters _neatGenomeParams.ConnectionWeightMutationProbability = 0.43; _neatGenomeParams.AddConnectionMutationProbability = 0.25; _neatGenomeParams.AddNodeMutationProbability = 1.0; _neatGenomeParams.DeleteConnectionMutationProbability = 0.003; _neatGenomeParams.NodeAuxStateMutationProbability = 0.0; _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; //_neatGenomeParams.ConnectionMutationInfoList.Add(new ConnectionMutationInfo(1, ConnectionPerturbanceType.JiggleGaussian, ConnectionSelectionType.Proportional, 0.15, 0, 0.0, 0.4)); } if (name == "Big mutation") { // Big mutation parameters _neatGenomeParams.ConnectionWeightMutationProbability = 0.65; _neatGenomeParams.AddConnectionMutationProbability = 0.48; _neatGenomeParams.AddNodeMutationProbability = 1.0; _neatGenomeParams.DeleteConnectionMutationProbability = 0.003; _neatGenomeParams.NodeAuxStateMutationProbability = 0.0; _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; //_neatGenomeParams.ConnectionMutationInfoList.Add(new ConnectionMutationInfo(1, ConnectionPerturbanceType.JiggleGaussian, ConnectionSelectionType.Proportional, 0.9, 0, 0.0, 0.4)); } if (name == "Novelty") { //Novelty parameters _neatGenomeParams.ConnectionWeightMutationProbability = 0.87; _neatGenomeParams.AddConnectionMutationProbability = 0.67; _neatGenomeParams.AddNodeMutationProbability = 1.0; _neatGenomeParams.DeleteConnectionMutationProbability = 0.003; _neatGenomeParams.NodeAuxStateMutationProbability = 0.0; _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; //_neatGenomeParams.ConnectionMutationInfoList.Add(new ConnectionMutationInfo(1, ConnectionPerturbanceType.JiggleGaussian, ConnectionSelectionType.Proportional, 0.9, 0, 0.0, 0.4)); } }
/// <summary> /// For ESP. Recurrent (cyclic) network, with fixed time-steps. /// </summary> public static NetworkActivationScheme CreateEspCyclic(int timestepsPerActivation) { NetworkActivationScheme scheme = new NetworkActivationScheme(); scheme._acyclicNetwork = false; scheme._timestepsPerActivation = timestepsPerActivation; scheme._relaxingActivation = false; scheme._fastFlag = true; scheme._esp = true; return(scheme); }
/// <summary> /// Create a relaxing activation scheme (suitable for cyclic networks only). /// 'fastFlag' indicates if a fast network implementation should be used. /// </summary> public static NetworkActivationScheme CreateCyclicRelaxingActivationScheme(double signalDeltaThreshold, int maxTimesteps, bool fastFlag) { NetworkActivationScheme scheme = new NetworkActivationScheme(); scheme._acyclicNetwork = false; scheme._signalDeltaThreshold = signalDeltaThreshold; scheme._maxTimesteps = maxTimesteps; scheme._relaxingActivation = true; scheme._fastFlag = fastFlag; return(scheme); }
/// <summary> /// Constructs with the provided substrate, CPPN activation scheme and substrate /// network activation scheme. /// </summary> public HyperNeatDecoder(Substrate substrate, NetworkActivationScheme activationSchemeCppn, NetworkActivationScheme activationSchemeSubstrate, bool lengthCppnInput) { _substrate = substrate; _activationSchemeCppn = activationSchemeCppn; _activationSchemeSubstrate = activationSchemeSubstrate; _decodeCppnMethod = GetDecodeCppnMethod(_activationSchemeCppn); _createSubstrateNetworkMethod = GetCreateSubstrateNetworkMethod(activationSchemeSubstrate); _lengthCppnInput = lengthCppnInput; }
private DecodeGenome GetDecodeMethod(NetworkActivationScheme activationScheme) { if (activationScheme.AcyclicNetwork) { throw new Exception("The FastCyclicNeatGenomeDecoder only supports activation schemes specifying fast CYCLIC networks."); } if (activationScheme.FastFlag) { return(DecodeToFastCyclicNetwork); } throw new Exception("The FastCyclicNeatGenomeDecoder only supports activation schemes specifying FAST cyclic networks."); }
public override void Initialize(string name, XmlElement xmlConfig) { base.Initialize(name, xmlConfig); var substrateElements = xmlConfig.GetElementsByTagName("Substrate"); if (substrateElements.Count != 1) { throw new ArgumentException("Must be only one substrate element in the xml."); } _substrate = ExperimentUtils.ReadSubstrateFromXml(xmlConfig.GetElementsByTagName("Substrate")[0] as XmlElement, xmlConfig.GetElementsByTagName("SubstrateSettings")[0] as XmlElement); _cppnActivationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "CPPNActivation"); _cppnInputLength = XmlUtils.TryGetValueAsBool(xmlConfig, "CPPNDistanceInput") ?? false; }
/// <summary> /// Create a relaxing activation scheme (suitable for cyclic networks only). /// 'fastFlag' indicates if a fast network implementation should be used. /// </summary> public static NetworkActivationScheme CreateCyclicRelaxingActivationScheme(double signalDeltaThreshold, int maxTimesteps, bool fastFlag) { NetworkActivationScheme scheme = new NetworkActivationScheme(); scheme._acyclicNetwork = false; scheme._signalDeltaThreshold = signalDeltaThreshold; scheme._maxTimesteps = maxTimesteps; scheme._relaxingActivation = true; scheme._fastFlag = fastFlag; return scheme; }
/// <summary> /// Create an activation scheme with a fixed number of activation timesteps (suitable for cyclic networks only). /// 'fastFlag' indicates if a fast network implementation should be used. /// </summary> public static NetworkActivationScheme CreateCyclicFixedTimestepsScheme(int timestepsPerActivation, bool fastFlag) { NetworkActivationScheme scheme = new NetworkActivationScheme(); scheme._acyclicNetwork = false; scheme._timestepsPerActivation = timestepsPerActivation; scheme._relaxingActivation = false; scheme._fastFlag = fastFlag; return scheme; }
/// <summary> /// Create an activation scheme for acyclic networks. /// </summary> public static NetworkActivationScheme CreateAcyclicScheme() { NetworkActivationScheme scheme = new NetworkActivationScheme(); scheme._acyclicNetwork = true; return scheme; }