Represents network activation schemes. E.g. fixed number of activation timesteps or activation until the network becomes 'relaxed'. Relaxed here means that no node's output value changed by more than some threshold value.
Ejemplo n.º 1
0
        /// <summary>
        /// Creates a CyclicNetwork from an INetworkDefinition.
        /// </summary>
        public static FastCyclicNetwork CreateFastCyclicNetwork(INetworkDefinition networkDef,
                                                                NetworkActivationScheme activationScheme,
                                                                bool boundedOutput)
        {
            FastConnection[]      fastConnectionArray;
            IActivationFunction[] activationFnArray;
            double[][]            neuronAuxArgsArray;
            InternalDecode(networkDef,
                           activationScheme.RelaxingActivation ? activationScheme.MaxTimesteps : activationScheme.TimestepsPerActivation,
                           out fastConnectionArray, out activationFnArray, out neuronAuxArgsArray);

            // Construct neural net.
            if (activationScheme.RelaxingActivation)
            {
                return(new FastRelaxingCyclicNetwork(fastConnectionArray,
                                                     activationFnArray,
                                                     neuronAuxArgsArray,
                                                     networkDef.NodeList.Count,
                                                     networkDef.InputNodeCount,
                                                     networkDef.OutputNodeCount,
                                                     activationScheme.MaxTimesteps,
                                                     activationScheme.SignalDeltaThreshold,
                                                     boundedOutput));
            }

            return(new FastCyclicNetwork(fastConnectionArray,
                                         activationFnArray,
                                         neuronAuxArgsArray,
                                         networkDef.NodeList.Count,
                                         networkDef.InputNodeCount,
                                         networkDef.OutputNodeCount,
                                         activationScheme.TimestepsPerActivation,
                                         boundedOutput));
        }
Ejemplo n.º 2
0
        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 configuration file parameters.
        /// </summary>
        /// <param name="name">The name of the experiment</param>
        /// <param name="xmlConfig">The parent XML configuration element</param>
        public virtual void Initialize(string name, XmlElement xmlConfig)
        {
            // Set all properties
            Name = name;
            DefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            Description = XmlUtils.GetValueAsString(xmlConfig, "Description");

            // Set all internal class variables
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            ComplexityRegulationStrategy = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            Complexitythreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            ParallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            // Set evolution/genome parameters
            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters
            {
                SpecieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"),
                InterspeciesMatingProportion = XmlUtils.GetValueAsDouble(xmlConfig,
                    "InterspeciesMatingProbability"),
                MinTimeAlive = XmlUtils.GetValueAsInt(xmlConfig, "MinTimeAlive")
            };
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);

            // Set experiment-specific parameters
            MaxTimesteps = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxTimesteps");
            MinSuccessDistance = XmlUtils.TryGetValueAsInt(xmlConfig, "MinSuccessDistance");
            MaxDistanceToTarget = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxDistanceToTarget");
            MazeVariant =
                MazeVariantUtl.convertStringToMazeVariant(XmlUtils.TryGetValueAsString(xmlConfig, "MazeVariant"));         
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a CyclicNetwork from an INetworkDefinition.
        /// </summary>
        public static FastCyclicNetwork CreateFastCyclicNetwork(INetworkDefinition networkDef,
                                                                NetworkActivationScheme activationScheme)
        {
            FastConnection[] fastConnectionArray;
            IActivationFunction[] activationFnArray;
            double[][] neuronAuxArgsArray;
            InternalDecode(networkDef, 
                           activationScheme.RelaxingActivation ? activationScheme.MaxTimesteps : activationScheme.TimestepsPerActivation,
                           out fastConnectionArray, out activationFnArray, out neuronAuxArgsArray);

            // Construct neural net.
            if(activationScheme.RelaxingActivation)
            {
                return new FastRelaxingCyclicNetwork(fastConnectionArray,
                                                     activationFnArray, 
                                                     neuronAuxArgsArray,
                                                     networkDef.NodeList.Count,
                                                     networkDef.InputNodeCount,
                                                     networkDef.OutputNodeCount,
                                                     activationScheme.MaxTimesteps,
                                                     activationScheme.SignalDeltaThreshold);
            }

            return new FastCyclicNetwork(fastConnectionArray,
                                         activationFnArray,
                                         neuronAuxArgsArray,
                                         networkDef.NodeList.Count,
                                         networkDef.InputNodeCount,
                                         networkDef.OutputNodeCount,
                                         activationScheme.TimestepsPerActivation);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a CyclicNetwork from an INetworkDefinition.
        /// </summary>
        public static CyclicNetwork CreateCyclicNetwork(INetworkDefinition networkDef,
                                                        NetworkActivationScheme activationScheme)
        {
            List <Neuron>     neuronList;
            List <Connection> connectionList;

            InternalDecode(networkDef, out neuronList, out connectionList);

            // Construct neural net.
            if (activationScheme.RelaxingActivation)
            {
                return(new RelaxingCyclicNetwork(neuronList,
                                                 connectionList,
                                                 networkDef.InputNodeCount,
                                                 networkDef.OutputNodeCount,
                                                 activationScheme.MaxTimesteps,
                                                 activationScheme.SignalDeltaThreshold));
            }

            return(new CyclicNetwork(neuronList,
                                     connectionList,
                                     networkDef.InputNodeCount,
                                     networkDef.OutputNodeCount,
                                     activationScheme.TimestepsPerActivation));
        }
 /// <summary>
 ///     SimulatorExperimentConfiguration constructor.
 /// </summary>
 /// <param name="experimentName">The experiment name.</param>
 /// <param name="mazeHeight">The height of the maze.</param>
 /// <param name="mazeWidth">The width of the maze.</param>
 /// <param name="mazeScaleMultiplier">
 ///     The maze scale multiplication factor (this is the scale on which the navigator was
 ///     evaluated, not at which the maze was evolved).
 /// </param>
 /// <param name="navigatorActivationScheme">The activation scheme (e.g. acyclic, cyclic) of the navigator ANN controller.</param>
 /// <param name="maxTimesteps">The maximum number of timesteps for one simulation trial.</param>
 /// <param name="minSuccessDistance">The minimum distance from the target to be considered a successful trial.</param>
 public SimulatorExperimentConfiguration(string experimentName, int mazeHeight, int mazeWidth,
     int mazeScaleMultiplier, NetworkActivationScheme navigatorActivationScheme, int maxTimesteps,
     int minSuccessDistance)
 {
     ExperimentName = experimentName;
     MazeHeight = mazeHeight*mazeScaleMultiplier;
     MazeWidth = mazeWidth*mazeScaleMultiplier;
     NavigatorAnnActivationScheme = navigatorActivationScheme;
     MaxTimesteps = maxTimesteps;
     MinSuccessDistance = minSuccessDistance;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a EspCyclicNetwork from a NeatGenome.
        /// </summary>
        public static EspCyclicNetwork CreateEspCyclicNetwork(
            NeatGenome givenGenome, NetworkActivationScheme activationScheme)
        {
            phenomeVariables = new PhenomeVariables();
            genome           = givenGenome;
            GetEasyVariables();
            phenomeVariables.timestepsPerActivation = activationScheme.TimestepsPerActivation;
            InternalDecode();

            /*foreach (KeyValuePair<int, int> entry in oldToNewIndex)
             * {
             *  UnityEngine.Debug.Log("old index " + entry.Key + " new index " + entry.Value);
             * }*/
            return(new EspCyclicNetwork(phenomeVariables));
        }
        /// <summary>
        ///     Initialize the experiment with configuration file parameters.
        /// </summary>
        /// <param name="name">The name of the experiment</param>
        /// <param name="xmlConfig">The parent XML configuration element</param>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            // Set all properties
            Name = name;
            DefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            Description = XmlUtils.GetValueAsString(xmlConfig, "Description");

            // Set all internal class variables
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStrategy = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexitythreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _parallOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            // Set evolution/genome parameters
            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
            NeatEvolutionAlgorithmParameters.SpecieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            NeatGenomeParameters = new NeatGenomeParameters();
        }
Ejemplo n.º 9
0
        public NeuromonExperiment(ExperimentSettings experimentSettings, NeatEvolutionAlgorithmParameters evolutionAlgorithmParameters, IPhenomeEvaluator<IBlackBox> neuromonPhenomeEvaluator, NeatGenomeParameters genomeParameters)
        {
            Name = experimentSettings.ExperimentName;
            Description = experimentSettings.Description;
            InputCount = experimentSettings.InputCount;
            OutputCount = experimentSettings.OutputCount;
            DefaultPopulationSize = experimentSettings.PopulationSize;

            _neuromonPhenomeEvaluator = neuromonPhenomeEvaluator;
            _complexityRegulationStrategy = experimentSettings.ComplexityRegulationStrategy;
            _complexityThreshold = experimentSettings.ComplexityThreshold;

            // Removed from .xml configuration. TODO: Possibly make configurable via json config
            _networkActivationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(1);

            NeatEvolutionAlgorithmParameters = evolutionAlgorithmParameters;
            NeatGenomeParameters = genomeParameters;
        }
        /// <summary>
        /// Creates a CyclicNetwork from an INetworkDefinition.
        /// </summary>
        public static CyclicNetwork CreateCyclicNetwork(INetworkDefinition networkDef,
                                                           NetworkActivationScheme activationScheme)
        {
            List<Neuron> neuronList;
            List<Connection> connectionList;
            InternalDecode(networkDef, out neuronList, out connectionList);

            // Construct neural net.
            if(activationScheme.RelaxingActivation)
            {
                return new RelaxingCyclicNetwork(neuronList,
                                                 connectionList,
                                                 networkDef.InputNodeCount,
                                                 networkDef.OutputNodeCount,
                                                 activationScheme.MaxTimesteps,
                                                 activationScheme.SignalDeltaThreshold);
            }

            return new CyclicNetwork(neuronList,
                                     connectionList,
                                     networkDef.InputNodeCount,
                                     networkDef.OutputNodeCount,
                                     activationScheme.TimestepsPerActivation);
        }
        /// <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;
        }
        /// <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;
        }
Ejemplo n.º 13
0
    public void Initialize(string name, XmlElement xmlConfig, int input, int output)
    {
        _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");

        _eaParams = new NeatEvolutionAlgorithmParameters();
        _eaParams.SpecieCount = _specieCount;
        _neatGenomeParams = new NeatGenomeParameters();
        _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;

        _inputCount = input;
        _outputCount = output;
    }
        /// <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);

            _visualFieldResolution = XmlUtils.GetValueAsInt(xmlConfig, "Resolution");
            _visualFieldPixelCount = _visualFieldResolution * _visualFieldResolution;
            _lengthCppnInput = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput");

            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters();
            //_neatGenomeParams = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);

            _resolutionReductionPerSide = XmlUtils.GetValueAsInt(xmlConfig, "ResolutionReductionPerSide");
            // Read in experiment domain-specific parameters
            _trainingImagesFilename = XmlUtils.TryGetValueAsString(xmlConfig, "TrainingImages");
            _numImageSamples = XmlUtils.GetValueAsInt(xmlConfig, "NumImageSamples");
            _learningRate = XmlUtils.GetValueAsDouble(xmlConfig, "LearningRate");
            _numBackpropIterations = XmlUtils.GetValueAsInt(xmlConfig, "NumBackpropagationIterations");
            _trainingSampleProportion = XmlUtils.GetValueAsDouble(xmlConfig, "TrainingSampleProportion");
        }
Ejemplo n.º 15
0
        /// <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");
            _timeStepsPerGeneration = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "TimeStepsPerGeneration");
            _stepReward = XmlUtils.GetValueAsInt(xmlConfig, "StepReward");
            _agentType =(AgentTypes) Enum.Parse(typeof(AgentTypes), XmlUtils.TryGetValueAsString(xmlConfig, "AgentType"));
            _plantLayout = (PlantLayoutStrategies)Enum.Parse(typeof(PlantLayoutStrategies), XmlUtils.TryGetValueAsString(xmlConfig, "PlantLayout"));
            _paradigm = (EvolutionParadigm)Enum.Parse(typeof(EvolutionParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "EvolutionParadigm"));
            bool? diverse = XmlUtils.TryGetValueAsBool(xmlConfig, "LogDiversity");
            if (diverse.HasValue && diverse.Value)
                _logDiversity = true;
            if (_agentType == AgentTypes.Social)
            {
                var memSection = xmlConfig.GetElementsByTagName("Memory")[0] as XmlElement;
                _memory = (MemoryParadigm)Enum.Parse(typeof(MemoryParadigm), XmlUtils.TryGetValueAsString(memSection, "Paradigm"));
                SocialAgent.DEFAULT_MEMORY_SIZE = XmlUtils.GetValueAsInt(memSection, "Size");
                if (_memory == MemoryParadigm.IncrementalGrowth)
                {
                    _memGens = XmlUtils.GetValueAsInt(memSection, "GrowthGenerations");
                    _maxMemorySize = XmlUtils.GetValueAsInt(memSection, "MaxSize");
                }
                _teaching = (TeachingParadigm)Enum.Parse(typeof(TeachingParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "TeachingParadigm"));
            }
            var species = new List<PlantSpecies>();

            var plants = xmlConfig.GetElementsByTagName("Plant");
            for (int i = 0; i < plants.Count; i++)
            {
                var plant = plants[i] as XmlElement;
                species.Add(new PlantSpecies(i)
                {
                    Name = XmlUtils.GetValueAsString(plant, "Name"),
                    Radius = XmlUtils.GetValueAsInt(plant, "Radius"),
                    Reward = XmlUtils.GetValueAsInt(plant, "Reward"),
                    Count = XmlUtils.GetValueAsInt(plant, "Count")
                });
            }
           
            Random random = new Random();
            var agents = new List<ForagingAgent>();
            const int NUM_AGENTS = 10;
            for (int i = 0; i < NUM_AGENTS; i++)
            {
                agents.Add(new SpinningAgent(i) { X = random.Next(500), Y = random.Next(500), Orientation = random.Next(360) });
            }

            List<Predator> predators = new List<Predator>();
            _predCount = XmlUtils.GetValueAsInt(xmlConfig, "Predators");
            var predStr = XmlUtils.TryGetValueAsString(xmlConfig, "PredatorDistribution");
            if (predStr != null)
                PredatorDistribution = (PredatorDistributionTypes)Enum.Parse(typeof(PredatorDistributionTypes), predStr, true);
            _predTypes = XmlUtils.GetValueAsInt(xmlConfig, "PredatorTypes");
            if (PredatorDistribution == PredatorDistributionTypes.Alternating)
                _predGens = XmlUtils.GetValueAsDouble(xmlConfig, "PredatorGenerations");
            _distinguishPreds = XmlUtils.GetValueAsBool(xmlConfig, "DistinguishPredators");

            _world = new World(agents, XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), species, predators)
            {
                AgentHorizon = XmlUtils.GetValueAsInt(xmlConfig, "AgentHorizon"),
                PlantLayoutStrategy = _plantLayout,
                StepReward = _stepReward,
                PredatorTypes = _predTypes
            };

            var outputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Outputs");
            var navigation = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsNavigate");
            var hiding = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsHide");
            _navigationEnabled = navigation.HasValue ? navigation.Value : false;
            _hidingEnabled = hiding.HasValue ? hiding.Value : false;
            if (!outputs.HasValue)
            {
                if (_navigationEnabled || _hidingEnabled)
                    _outputs = (_navigationEnabled ? 2 : 0) + (_hidingEnabled ? _predTypes + 1 : 0);
                else
                    _outputs = outputs.HasValue ? outputs.Value : 2;
            }
            else
                _outputs = outputs.Value;
            var inputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Inputs");
            _inputs = inputs.HasValue ? inputs.Value : _world.PlantTypes.Count() * World.SENSORS_PER_OBJECT_TYPE + (_distinguishPreds ? _predTypes : 1) * World.SENSORS_PER_OBJECT_TYPE + 1;

            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters()
            {
                ActivationFn = PlainSigmoid.__DefaultInstance
            };
            if (_teaching != TeachingParadigm.EgalitarianEvolvedAcceptability)
                _neatGenomeParams.InitialInterconnectionsProportion = 0.1;
        }
    /// <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");
            _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;
            _neatGenomeParams = new NeatGenomeParameters();
        }
        /// <summary>
        ///     Initialize the experiment with database configuration parameters.
        /// </summary>
        /// <param name="experimentDictionary">The handle to the experiment dictionary row pulled from the database.</param>
        public virtual void Initialize(ExperimentDictionary experimentDictionary)
        {
            // Set all properties
            Name = experimentDictionary.ExperimentName;
            DefaultPopulationSize = experimentDictionary.Primary_PopulationSize;
            Description = experimentDictionary.ExperimentName;

            // Set all internal class variables
            _activationScheme = NetworkActivationScheme.CreateAcyclicScheme();
            ComplexityRegulationStrategy = experimentDictionary.Primary_ComplexityRegulationStrategy;
            Complexitythreshold = experimentDictionary.Primary_ComplexityThreshold;
            ParallelOptions = new ParallelOptions();
            SerializeGenomeToXml = experimentDictionary.SerializeGenomeToXml;
            MaxEvaluations = (ulong) experimentDictionary.MaxEvaluations;
            MaxRestarts = experimentDictionary.MaxRestarts;

            // Set evolution/genome parameters
            NeatEvolutionAlgorithmParameters = ExperimentUtils.ReadNeatEvolutionAlgorithmParameters(
                experimentDictionary, true);
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(experimentDictionary, true);
            NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork;

            // Set experiment-specific parameters
            MaxTimesteps = experimentDictionary.MaxTimesteps;
            MinSuccessDistance = experimentDictionary.MinSuccessDistance;
            MaxDistanceToTarget = experimentDictionary.MaxDistanceToTarget ?? default(int);
            MazeVariant = MazeVariantUtil.convertStringToMazeVariant(experimentDictionary.ExperimentDomainName);
        }
Ejemplo n.º 19
0
        /// <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,

            };
        }
Ejemplo n.º 20
0
        /// <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>
        /// 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);
            _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);
            }
        }
        /// <summary>
        ///     Initialize the experiment with configuration file parameters.
        /// </summary>
        /// <param name="name">The name of the experiment</param>
        /// <param name="xmlConfig">The parent XML configuration element</param>
        /// <param name="evolutionDataLogger">The optional evolution data logger.</param>
        /// <param name="evaluationDataLogger">The optional evaluation data logger.</param>
        public virtual void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger,
            IDataLogger evaluationDataLogger)
        {
            // Set all properties
            Name = name;
            DefaultPopulationSize = XmlUtils.TryGetValueAsInt(xmlConfig, "PopulationSize") ?? default(int);
            Description = XmlUtils.GetValueAsString(xmlConfig, "Description");

            // Set all internal class variables
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            ComplexityRegulationStrategy = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            Complexitythreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            ParallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);
            SerializeGenomeToXml = XmlUtils.TryGetValueAsBool(xmlConfig, "DecodeGenomesToXml") ?? false;
            MaxGenerations = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxGenerations");
            MaxEvaluations = XmlUtils.TryGetValueAsULong(xmlConfig, "MaxEvaluations");
            MaxRestarts = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxRestarts");

            // Set evolution/genome parameters
            NeatEvolutionAlgorithmParameters = ExperimentUtils.ReadNeatEvolutionAlgorithmParameters(xmlConfig);
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);
            NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork;

            // Set experiment-specific parameters
            MaxTimesteps = XmlUtils.GetValueAsInt(xmlConfig, "MaxTimesteps");
            MinSuccessDistance = XmlUtils.GetValueAsInt(xmlConfig, "MinSuccessDistance");
            MaxDistanceToTarget = XmlUtils.GetValueAsInt(xmlConfig, "MaxDistanceToTarget");
            MazeVariant =
                MazeVariantUtil.convertStringToMazeVariant(XmlUtils.TryGetValueAsString(xmlConfig, "MazeVariant"));
        }
        /// <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);
        }
Ejemplo n.º 24
0
 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>
        ///     Initializes the experiment with some optional XML configutation data.
        /// </summary>
        /// <param name="name">The name of the experiment.</param>
        /// <param name="xmlConfig">The reference to the top-level configuration element for the experiment.</param>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            // Read in boiler plate configuration settings
            Name = name;
            Description = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            DefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            InputCount = OutputCount = XmlUtils.GetValueAsInt(xmlConfig, "AutoencoderSize");
            _numInitialHiddenNodes = XmlUtils.GetValueAsInt(xmlConfig, "NumInitialHiddenNodes");

            // Read in algorithm/logging configuration
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);
            _generationalLogFile = XmlUtils.TryGetValueAsString(xmlConfig, "GenerationalLogFile");

            // Construct NEAT EA parameters
            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
            NeatEvolutionAlgorithmParameters.SpecieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");

            // Construct NEAT genome parameters
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);
            NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            NeatGenomeParameters.ActivationFn = PlainSigmoid.__DefaultInstance;

            // Read in experiment domain-specific parameters
            _trainingImagesFilename = XmlUtils.TryGetValueAsString(xmlConfig, "TrainingImages");
            _numImageSamples = XmlUtils.GetValueAsInt(xmlConfig, "NumImageSamples");
            _learningRate = XmlUtils.GetValueAsDouble(xmlConfig, "LearningRate");
            _numBackpropIterations = XmlUtils.GetValueAsInt(xmlConfig, "NumBackpropagationIterations");
            _trainingSampleProportion = XmlUtils.GetValueAsDouble(xmlConfig, "TrainingSampleProportion");
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     Initialize the experiment with some optional XML configutation data.
        /// </summary>
        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);
            _generationalLogFile = XmlUtils.TryGetValueAsString(xmlConfig, "GenerationalLogFile");

            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
            NeatEvolutionAlgorithmParameters.SpecieCount = _specieCount;
            NeatGenomeParameters = new NeatGenomeParameters();
            NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            NeatGenomeParameters.ActivationFn = PlainSigmoid.__DefaultInstance;
        }
        /// <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();
        }
        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();
        }