public LearningRateExperiment() { _neatGenomeParams = new NeatGenomeParameters() { ActivationFn = PlainSigmoid.__DefaultInstance }; }
public BundledExperimentSettings(int population, int batchSize, NeatEvolutionAlgorithmParameters eaParams, NeatGenomeParameters genomeParams) { Population = population; BatchSize = batchSize; EAParams = eaParams; GenomeParams = genomeParams; }
/// <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; }
void Start() { _frames = MaxFrames; _gen = MaxGen; RNG.Init(); NeatGenomeParameters neatGenomeParameters = new NeatGenomeParameters { InitialInterconnectionsProportion = 0.5f, FeedforwardOnly = true }; _genomeFactory = new NeatGenomeFactory(10, 2, neatGenomeParameters); _parameters = new[] { new EvolutionParameters(new NoveltySelection(5), new NoveltySearch.Containers.Grid(-31, 10, -4, 14, 41, 18), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new NoveltySelection(5), new Archive(1), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new ContainerSelection(), new NoveltySearch.Containers.Grid(-31, 10, -4, 14, 41, 18), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new ContainerSelection(), new Archive(1), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new FitnessSelection(), new DummyContainer(), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new ClearingSelection(10, 6), new DummyContainer(), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new ClearingSelection(20, 8), new DummyContainer(), new Variation[] { new Crossover(), new Mutation() }), new EvolutionParameters(new DeterministicCrowdingSelection(), new DummyContainer(), new Variation[] { new Mutation() }), new EvolutionParameters(new RestrictedTournamentSelection(8), new DummyContainer(), new Variation[] { new Mutation() }), new EvolutionParameters(new DummySelection(), new DummyContainer(), new Variation[] { new Crossover(), new Mutation() }), }; /*NeatGenome genome = _genomeFactory.CreateGenome(0); * while (!CyclicNetworkTest.IsNetworkCyclic(genome)) { * genome = genome.CreateOffspring(0); * } * UnityEditor.EditorApplication.isPlaying = false;*/ }
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); }
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; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; // Determine what function to regress. string fnIdStr = XmlUtils.GetValueAsString(xmlConfig, "Function"); FunctionId fnId = (FunctionId)Enum.Parse(typeof(FunctionId), fnIdStr); _fn = FunctionUtils.GetFunction(fnId); // Read parameter sampling scheme settings. int sampleResolution = XmlUtils.GetValueAsInt(xmlConfig, "SampleResolution"); double sampleMin = XmlUtils.GetValueAsDouble(xmlConfig, "SampleMin"); double sampleMax = XmlUtils.GetValueAsDouble(xmlConfig, "SampleMax"); _paramSamplingInfo = new ParamSamplingInfo(sampleMin, sampleMax, sampleResolution); }
/// <summary> /// Constructs with the provided IActivationFunctionLibrary, NeatGenomeParameters and ID generators. /// </summary> public RbfGenomeFactory(int inputNeuronCount, int outputNeuronCount, IActivationFunctionLibrary activationFnLibrary, NeatGenomeParameters neatGenomeParams, UInt32IdGenerator genomeIdGenerator, UInt32IdGenerator innovationIdGenerator) : base(inputNeuronCount, outputNeuronCount, activationFnLibrary, neatGenomeParams, genomeIdGenerator, innovationIdGenerator) { }
/// <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> /// 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; }
/// <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> /// 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)); } }
public void Initialize(string name, XmlElement xmlConfig) { NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters(); NeatEvolutionAlgorithmParameters.SpecieCount = 10; // The NeatGenomeParameters object is passed to the NeatGenomeFactory. // The NeatGenomeFactory creates a NeatGenome (which is an INetworkDefinition). // The NeatGenome is constructed using the NeatGenomeParameters. // For example, the NeatGenomeParameters define what activation function to use. NeatGenomeParameters = new NeatGenomeParameters(); // Create fast cyclic activation scheme with 3 evaluations for convergence _activationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(3, true); }
/// <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"); //snake specific params _swparams = SnakeUtils.GetParamsFromXml(xmlConfig); _trialsPerEvaluation = XmlUtils.TryGetValueAsInt(xmlConfig, "TrialsPerEvaluation") ?? _trialsPerEvaluation; _maxTicksWithoutEating = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxTicksWithoutEating") ?? (_swparams.Height * _swparams.Width + _swparams.TicksBetweenFood); _inputMapperName = XmlUtils.TryGetValueAsString(xmlConfig, "InputMapping") ?? _inputMapperName; _outputMapperName = XmlUtils.TryGetValueAsString(xmlConfig, "OutputMapping") ?? _outputMapperName; _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; //string nameoftype = (string ) typeof(GridInputMapper).GetProperty("Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null, null); Type inputType = Assembly.GetAssembly(typeof(IInputMapper)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && (typeof(IInputMapper).IsAssignableFrom(myType)) && _inputMapperName == (string)myType.GetProperty("Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null, null)).First(); _inputMapper = (IInputMapper)Activator.CreateInstance(inputType, _swparams); Type outputType = Assembly.GetAssembly(typeof(IOutputMapper)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && (typeof(IOutputMapper).IsAssignableFrom(myType)) && _outputMapperName == (string)myType.GetProperty("Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null, null)).First(); _outputMapper = (IOutputMapper)Activator.CreateInstance(outputType); //foreach (Type type in //Assembly.GetAssembly(typeof(IInputMapper)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(IInputMapper) ))) //{ // SnakeRunnerFactory srf = (SnakeRunnerFactory) Activator.CreateInstance(type, swOriginal); // if (srf.Name == _ioLayers) // { // _srf = srf; // break; // } //} }
private void GenomesToAcceptability(IList <TGenome> genomeList) { string TEMP_NETWORK_FILE = string.Format("____temp{0}____network.xml", TrialId); var neatGenomeParams = new NeatGenomeParameters() { ActivationFn = PlainSigmoid.__DefaultInstance, InitialInterconnectionsProportion = 1 }; int inputs = _world.PlantTypes.Count() * World.SENSORS_PER_OBJECT_TYPE + _world.Predators.Count() * World.SENSORS_PER_OBJECT_TYPE + 1; int outputs = 2; var factory = new NeatGenomeFactory(inputs, outputs, neatGenomeParams); for (int i = 0; i < _agents.Length; i++) { // Decode the genome. IBlackBox phenome = _genomeDecoder.Decode(genomeList[i]); IAcceptabilityFunction accept = new RecurrentNeuralAcceptability(phenome); // Check that the genome is valid. if (phenome == null) { Console.WriteLine("Couldn't decode genome {0}!", i); _agents[i] = new SpinningAgent(i); continue; } // Create a feed forward network with 10 hidden nodes and random weights SocialExperiment.CreateNetwork(TEMP_NETWORK_FILE, inputs, outputs); using (var xr = XmlReader.Create(TEMP_NETWORK_FILE)) { var controllerGenome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, factory)[0]; var controllerPhenome = _genomeDecoder.Decode((TGenome)controllerGenome); _agents[i] = new SocialAgent(i, _genomeList[i].SpecieIdx, controllerPhenome, _agentsNavigate, _agentsHide, accept) { MemorySize = CurrentMemorySize }; var network = (FastCyclicNetwork)controllerPhenome; network.Momentum = ((SocialAgent)_agents[i]).Momentum; network.BackpropLearningRate = ((SocialAgent)_agents[i]).LearningRate; } } File.Delete(TEMP_NETWORK_FILE); }
/// <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.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); }
private void Start() { int populationSize = 100; NetworkActivationScheme activationScheme = NetworkActivationScheme.CreateAcyclicScheme(); NeatGenomeParameters neatParams = new NeatGenomeParameters(); neatParams.ActivationFn = TanH.__DefaultInstance; neatParams.FeedforwardOnly = activationScheme.AcyclicNetwork; IGenomeDecoder <NeatGenome, IBlackBox> neatDecoder = new NeatGenomeDecoder(activationScheme); IGenomeFactory <NeatGenome> neatFactory = new NeatGenomeFactory(3, 3, neatParams); List <NeatGenome> genomeList = neatFactory.CreateGenomeList(populationSize, 0); ArenaEvaluator evaluator = GetComponent <ArenaEvaluator>(); evaluator.Initialize(neatDecoder); IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); // Evolution parameters NeatEvolutionAlgorithmParameters neatEvolutionParams = new NeatEvolutionAlgorithmParameters(); neatEvolutionParams.SpecieCount = 10; ISpeciationStrategy <NeatGenome> speciationStrategy = new KMeansClusteringStrategy <NeatGenome>(distanceMetric); IComplexityRegulationStrategy complexityRegulationStrategy = new DefaultComplexityRegulationStrategy(ComplexityCeilingType.Absolute, 10); NeatEvolutionAlgorithm <NeatGenome> ea = GetComponent <UnityEvolutionAlgorithm>(); ea.Construct(neatEvolutionParams, speciationStrategy, complexityRegulationStrategy, new NullGenomeListEvaluator <NeatGenome, IBlackBox>()); ea.Initialize(evaluator, neatFactory, genomeList); ea.UpdateScheme = new UpdateScheme(1); // This needs to be set AFTER Initialize is called ea.PausedEvent += (sender, e) => { //ea.StartContinue(); }; ea.GenerationEvent += (sender, gen) => { Debug.Log($"Generation {gen}"); Debug.Log($"Highest fitness: {ea.CurrentChampGenome.EvaluationInfo.Fitness}"); nnMesh.GenerateMesh(ea.CurrentChampGenome); ea.RequestPause(); StartCoroutine(PauseRoutine(ea)); }; ea.StartContinue(); }
public void Initialize(string name, XmlElement xmlConfig, int input, int output, int populationSize, int specieCount) { _name = name; _populationSize = populationSize; //XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = 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"); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; _inputCount = input; _outputCount = output; }
private void InitTeam(double teamDisc, NeatEvolutionAlgorithm <NeatGenome> team, NeatEvolutionAlgorithm <NeatGenome> opponent) { NeatGenomeParameters genomeParams = new NeatGenomeParameters(); genomeParams.FeedforwardOnly = true; //genomeParams.InitialInterconnectionsProportion = 1.0; IGenomeFactory <NeatGenome> genomeFactory = new NeatGenomeFactory(7 * 6, 7, genomeParams); IGenomeDecoder <NeatGenome, IBlackBox> decoder = new NeatGenomeDecoder(SharpNeat.Decoders.NetworkActivationScheme.CreateAcyclicScheme()); IGenomeListEvaluator <NeatGenome> evaluator = new CacheFirstParallelGenomeListEvaluator <NeatGenome, IBlackBox>( decoder, new ConnectFourEvaluator(teamDisc, opponent, decoder)); team.UpdateEvent += ((sender, eventArgs) => OnUpdate()); team.Initialize(evaluator, genomeFactory, populationSize); }
public void Initialize(string name, XmlElement xmlConfig) { // Read these from Domain XML file _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationSchemeCppn = ExperimentUtils.CreateActivationScheme(xmlConfig, "ActivationCppn"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount / 2; _visualFieldResolution = XmlUtils.GetValueAsInt(xmlConfig, "Resolution"); _visualFieldPixelCount = _visualFieldResolution * _visualFieldResolution; _lengthCppnInput = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput"); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; // Set these manually, use a high mutator just to test the water _neatGenomeParams = new NeatGenomeParameters() { AddConnectionMutationProbability = 0.10, DeleteConnectionMutationProbability = 0.10, ConnectionWeightMutationProbability = 0.90, AddNodeMutationProbability = 0.05, InitialInterconnectionsProportion = 0.10 }; // Clear OUTPUT and FITNESS directories before starting var directory = new DirectoryInfo(Constants.OUTPUT_DIR); directory.Empty(); directory = new DirectoryInfo(Constants.FITNESS_DIR); directory.Empty(); directory = new DirectoryInfo(Constants.PLOTS_DIR); directory.Empty(); }
/// <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"); _activationSchemeCppn = ExperimentUtils.CreateActivationScheme(xmlConfig, "ActivationCppn"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _lengthCppnInput = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput"); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationSchemeCppn.AcyclicNetwork; _neatGenomeParams.InitialInterconnectionsProportion = 0.5; }
public void Initialize(string name, XmlElement xmlConfig) { Name = name; DefaultPopulationSize = 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); NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters { SpecieCount = _specieCount }; NeatGenomeParameters = new NeatGenomeParameters { FeedforwardOnly = _activationScheme.AcyclicNetwork }; // var figterType = XmlUtils.TryGetValueAsString(xmlConfig, "Figter"); // var type = Type.GetType(figterType); }
public BattleExperiment() { _activationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(2, true); _eaParams = new NeatEvolutionAlgorithmParameters(); _neatGenomeParams = new NeatGenomeParameters(); SharpNeat.Network.SReLU func = (SharpNeat.Network.SReLU) new SharpNeat.Network.SReLU(); func.SetParameters(-0.8, 0.8, 0.05); _neatGenomeParams.ActivationFn = func; _neatGenomeParams.AddConnectionMutationProbability = 0.7; _neatGenomeParams.AddNodeMutationProbability = 0.2; _neatGenomeParams.DeleteConnectionMutationProbability = 0.4; _neatGenomeParams.ConnectionWeightMutationProbability = 0.94; _neatGenomeParams.InitialInterconnectionsProportion = 0; _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; }
/// <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); ExperimentUtils.ReadRbfAuxArgMutationConfig(xmlConfig, out _rbfMutationSigmaCenter, out _rbfMutationSigmaRadius); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; _neatGenomeParams.ConnectionWeightMutationProbability = 0.788; _neatGenomeParams.AddConnectionMutationProbability = 0.001; _neatGenomeParams.AddConnectionMutationProbability = 0.01; _neatGenomeParams.NodeAuxStateMutationProbability = 0.2; _neatGenomeParams.DeleteConnectionMutationProbability = 0.001; // Determine what function to regress. string fnIdStr = XmlUtils.GetValueAsString(xmlConfig, "Function"); FunctionId fnId = (FunctionId)Enum.Parse(typeof(FunctionId), fnIdStr); _func = FunctionRegressionEvaluator.GetFunction(fnId); // Read parameter sampling scheme settings. int sampleResolution = XmlUtils.GetValueAsInt(xmlConfig, "SampleResolution"); double sampleMin = XmlUtils.GetValueAsDouble(xmlConfig, "SampleMin"); double sampleMax = XmlUtils.GetValueAsDouble(xmlConfig, "SampleMax"); int paramCount = _func.InputCount; _paramSamplingInfoArr = new ParameterSamplingInfo[paramCount]; for (int i = 0; i < paramCount; i++) { _paramSamplingInfoArr[i] = new ParameterSamplingInfo(sampleMin, sampleMax, sampleResolution); } }
public void Initialize(string name, XmlElement xmlConfig, string givenUserName) { _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); ActiveUsersList <NeatGenome> .PopulationSize = _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"); ActiveUsersList <NeatGenome> .MaxNumberOfUsers = XmlUtils.GetValueAsInt(xmlConfig, "MaxSimultaneousUsers"); ActiveUsersList <NeatGenome> .PortsPerUser = XmlUtils.GetValueAsInt(xmlConfig, "PortsPerUser"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); System.Diagnostics.Debug.Assert(CheckActivationScheme(_activationScheme)); userName = givenUserName; }
/// <summary> /// Initialize the experiment with some optional XML configuration data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { T GetValueAsEnum <T>(string e) { string r = XmlUtils.GetValueAsString(xmlConfig, e); return((T)System.Enum.Parse(typeof(T), r)); } _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"); _numberOfGames = XmlUtils.GetValueAsInt(xmlConfig, "IPDGames"); int seed = XmlUtils.GetValueAsInt(xmlConfig, "RandomPlayerSeed"); int randoms = XmlUtils.GetValueAsInt(xmlConfig, "RandomPlayerCount"); string os = XmlUtils.TryGetValueAsString(xmlConfig, "StaticOpponents"); _opponentPool = CreatePool(seed, randoms, (os == null) ? new Opponent[0] : System.Array.ConvertAll(os.Split(','), (string o) => { return((Opponent)System.Enum.Parse(typeof(Opponent), o, true)); })); _evaluationLimit = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "EvaluationLimit"); _evaluationMode = GetValueAsEnum <EvaluationMode>("EvaluationMode"); _noveltyMetric = GetValueAsEnum <NoveltyMetric>("NoveltyMetric"); _noveltyK = XmlUtils.GetValueAsInt(xmlConfig, "NoveltyK"); _randomRobustCheck = XmlUtils.GetValueAsInt(xmlConfig, "RandomRobustCheck"); _pastInputReach = XmlUtils.GetValueAsInt(xmlConfig, "PastInputReach"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; }
/// <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); ExperimentUtils.ReadRbfAuxArgMutationConfig(xmlConfig, out _rbfMutationSigmaCenter, out _rbfMutationSigmaRadius); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.ConnectionWeightMutationProbability = 0.788; _neatGenomeParams.AddConnectionMutationProbability = 0.001; _neatGenomeParams.AddConnectionMutationProbability = 0.01; _neatGenomeParams.NodeAuxStateMutationProbability = 0.2; _neatGenomeParams.DeleteConnectionMutationProbability = 0.001; _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; }
public NeatExperiment(Simulation simulation) { _simulation = simulation; _name = "Trader"; _populationSize = 100; _specieCount = 1; _activationScheme = NetworkActivationScheme.CreateAcyclicScheme(); _complexityRegulationStr = "Relative"; _complexityThreshold = 10; _description = "Generate trader neural network"; _parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 2 }; UnityThread.SetUnityValue(() => _inputCount = 6 + UnityEngine.Object.FindObjectsOfType <Coin>().Length * 5); _outputCount = 8; _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters(); _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork; //_neatGenomeParams.ActivationFn = LeakyReLU.__DefaultInstance; _neatGenomeParams.ActivationFn = SharpNeat.Network.SReLU.__DefaultInstance; // Create a genome factory with our neat genome parameters object and the appropriate number of input and output neuron genes. _genomeFactory = CreateGenomeFactory(); // Create an initial population of randomly generated genomes. _genomeList = _genomeFactory.CreateGenomeList(_populationSize, 0); // Create evolution algorithm and attach update event. _ea = CreateEvolutionAlgorithm(_genomeFactory, _genomeList); // _ea.UpdateEvent += new EventHandler(ea_UpdateEvent); // Start algorithm (it will run on a background thread). _ea.StartContinue(); }
/// <summary> /// Initialize the experiment with some optional XML configutation data. /// </summary> public void Initialize(string name, XmlElement xmlConfig) { _name = name; var outputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Outputs"); _outputs = outputs.HasValue ? outputs.Value : 2; _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"); _timeStepsPerGeneration = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "TimeStepsPerGeneration"); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; _neatGenomeParams = new NeatGenomeParameters() { ActivationFn = PlainSigmoid.__DefaultInstance, InitialInterconnectionsProportion = 1, }; }