Esempio n. 1
0
 /// <summary>
 ///     Reads NEAT evolution algorithm parameters from the database.
 /// </summary>
 /// <param name="experimentDictionary">Reference to the experiment dictionary table.</param>
 /// <param name="isPrimary">Flag indicating whether this is the primary or an initialization algorithm.</param>
 /// <returns>Initialized NEAT evolution algorithm parameters.</returns>
 public static EvolutionAlgorithmParameters ReadNeatEvolutionAlgorithmParameters(
     ExperimentDictionary experimentDictionary,
     bool isPrimary)
 {
     return(isPrimary
         ? new EvolutionAlgorithmParameters
     {
         SpecieCount = experimentDictionary.Primary_NumSpecies,
         InterspeciesMatingProportion = experimentDictionary.Primary_InterspeciesMatingProbability,
         ElitismProportion = experimentDictionary.Primary_ElitismProportion,
         SelectionProportion = experimentDictionary.Primary_SelectionProportion,
         OffspringAsexualProportion = experimentDictionary.Primary_AsexualProbability,
         OffspringSexualProportion = experimentDictionary.Primary_CrossoverProbability
     }
         : new EvolutionAlgorithmParameters
     {
         SpecieCount = experimentDictionary.Initialization_NumSpecies ?? default(int),
         InterspeciesMatingProportion =
             experimentDictionary.Initialization_InterspeciesMatingProbability ?? default(double),
         ElitismProportion = experimentDictionary.Initialization_ElitismProportion ?? default(double),
         SelectionProportion = experimentDictionary.Initialization_SelectionProportion ?? default(double),
         OffspringAsexualProportion =
             experimentDictionary.Initialization_AsexualProbability ?? default(double),
         OffspringSexualProportion =
             experimentDictionary.Initialization_CrossoverProbability ?? default(double)
     });
 }
Esempio n. 2
0
 /// <summary>
 ///     Reads NEAT genome parameters from the database.
 /// </summary>
 /// <param name="experimentDictionary">Reference to experiment dictionary table.</param>
 /// <param name="isPrimary">Flag indicating whether this is the primary or an initialization algorithm.</param>
 /// <returns>Initialized NEAT genome parameters.</returns>
 public static NeatGenomeParameters ReadNeatGenomeParameters(ExperimentDictionary experimentDictionary,
                                                             bool isPrimary)
 {
     return(isPrimary
         ? new NeatGenomeParameters
     {
         InitialInterconnectionsProportion = experimentDictionary.Primary_ConnectionProportion,
         ConnectionWeightMutationProbability =
             experimentDictionary.Primary_MutateConnectionWeightsProbability,
         AddConnectionMutationProbability = experimentDictionary.Primary_MutateAddConnectionProbability,
         AddNodeMutationProbability = experimentDictionary.Primary_MutateAddNeuronProbability,
         DeleteConnectionMutationProbability =
             experimentDictionary.Primary_MutateDeleteConnectionProbability,
         ConnectionWeightRange = experimentDictionary.Primary_ConnectionWeightRange
     }
         : new NeatGenomeParameters
     {
         InitialInterconnectionsProportion =
             experimentDictionary.Initialization_ConnectionProportion ?? default(double),
         ConnectionWeightMutationProbability =
             experimentDictionary.Initialization_MutateConnectionWeightsProbability ?? default(double),
         AddConnectionMutationProbability =
             experimentDictionary.Initialization_MutateAddConnectionProbability ?? default(double),
         AddNodeMutationProbability =
             experimentDictionary.Initialization_MutateAddNeuronProbability ?? default(double),
         DeleteConnectionMutationProbability =
             experimentDictionary.Initialization_MutateDeleteConnectionProbability ?? default(double),
         ConnectionWeightRange = experimentDictionary.Initialization_ConnectionWeightRange ?? default(double)
     });
 }
Esempio n. 3
0
        /// <summary>
        ///     Reads behavior characterization parameters from the database.
        /// </summary>
        /// <param name="experiment">The experiment dictionary entity.</param>
        /// <param name="isPrimary">
        ///     Boolean flag indicating whether this is the primary behavior characterization or the behavior
        ///     characterization used for experiment initialization.
        /// </param>
        /// <returns></returns>
        public static IBehaviorCharacterizationFactory ReadBehaviorCharacterizationFactory(
            ExperimentDictionary experiment,
            bool isPrimary)
        {
            // Read behavior characterization
            var behaviorCharacterizationName = isPrimary
                ? experiment.Primary_BehaviorCharacterizationName
                : experiment.Initialization_BehaviorCharacterizationName;

            // Ensure that the behavior was specified
            if (behaviorCharacterizationName == null)
            {
                throw new ArgumentException("Missing or invalid BehaviorConfig settings.");
            }

            IMinimalCriteria minimalCriteria = null;

            // Get the appropriate minimal criteria type
            var mcType = BehaviorCharacterizationUtil.ConvertStringToMinimalCriteria(isPrimary
                ? experiment.Primary_MCS_MinimalCriteriaName
                : experiment.Initialization_MCS_MinimalCriteriaName);

            // Starting location used in most criterias
            double xStart, yStart;

            switch (mcType)
            {
            case MinimalCriteriaType.EuclideanLocation:

                // TODO: Not implemented at the database layer yet

                break;

            case MinimalCriteriaType.FixedPointEuclideanDistance:

                // Read in the starting coordinates and the minimum required distance traveled
                xStart = isPrimary
                        ? experiment.Primary_MCS_MinimalCriteriaStartX ?? default(double)
                        : experiment.Initialization_MCS_MinimalCriteriaStartX ?? default(double);
                yStart = isPrimary
                        ? experiment.Primary_MCS_MinimalCriteriaStartY ?? default(double)
                        : experiment.Initialization_MCS_MinimalCriteriaStartY ?? default(double);
                var minimumDistanceTraveled = isPrimary
                        ? experiment.Primary_MCS_MinimalCriteriaThreshold ?? default(double)
                        : experiment.Initialization_MCS_MinimalCriteriaThreshold ?? default(double);

                // Set the euclidean distance minimal criteria on the behavior characterization
                minimalCriteria = new FixedPointEuclideanDistanceCriteria(xStart, yStart,
                                                                          minimumDistanceTraveled);

                break;

            case MinimalCriteriaType.Mileage:

                // Read in the starting coordinates and minimum required total distance traveled (mileage)
                xStart = isPrimary
                        ? experiment.Primary_MCS_MinimalCriteriaStartX ?? default(double)
                        : experiment.Initialization_MCS_MinimalCriteriaStartX ?? default(double);
                yStart = isPrimary
                        ? experiment.Primary_MCS_MinimalCriteriaStartY ?? default(double)
                        : experiment.Initialization_MCS_MinimalCriteriaStartY ?? default(double);
                var minimumMileage = isPrimary
                        ? experiment.Primary_MCS_MinimalCriteriaThreshold ?? default(double)
                        : experiment.Initialization_MCS_MinimalCriteriaThreshold ?? default(double);

                // Set the mileage minimal criteria on the behavior characterization
                minimalCriteria = new MileageCriteria(xStart, yStart, minimumMileage);

                break;
            }

            // Parse and generate the appropriate behavior characterization factory
            var behaviorCharacterizationFactory =
                BehaviorCharacterizationUtil.GenerateBehaviorCharacterizationFactory(behaviorCharacterizationName,
                                                                                     minimalCriteria);

            return(behaviorCharacterizationFactory);
        }