private void setWeights(int mu, RecombinationType recombinationType) { double[] w = new double[mu]; if (recombinationType == RecombinationType.equal) { for (int i = 0; i < mu; ++i) { w[i] = 1; } } else if (recombinationType == RecombinationType.linear) { for (int i = 0; i < mu; ++i) { w[i] = mu - i; } } else { for (int i = 0; i < mu; ++i) { w[i] = (Math.Log(mu + 1) - Math.Log(i + 1)); } } setWeights(w); }
public void setRecombinationWeights(RecombinationType recombinationType) { if (locked != 0) { error("parameters cannot be set anymore"); } this.recombinationType = recombinationType; }
public void setRecombination(int mu, RecombinationType recombinationType) { if (locked != 0) { error("parameters are locked"); } this.mu = mu; this.recombinationType = recombinationType; }
/// <summary> /// Defines the parental haplotypes according to the recombination type /// </summary> /// <param name="recType"></param> public void DefineParentalHaplotypes(RecombinationType recType) { mother = new Individ(); father = new Individ(); Random s_Random = new Random(); switch (recType) { case RecombinationType.Backcross: for (int i = 0; i < mother.Haplotype0.Length; i++) { mother.Haplotype0[i] = 0; } for (int i = 0; i < father.Haplotype0.Length; i++) { father.Haplotype0[i] = 1; } break; case RecombinationType.BackcrossWithNoise: for (int i = 0; i < mother.Haplotype0.Length; i++) { int perCent = s_Random.Next(0, 100); if (perCent < 20) { mother.Haplotype0[i] = 1; } else { mother.Haplotype0[i] = 0; } } for (int i = 0; i < father.Haplotype0.Length; i++) { int perCent = s_Random.Next(0, 100); if (perCent < 20) { mother.Haplotype0[i] = 0; } else { mother.Haplotype0[i] = 1; } } break; } }
public ExperimentParameters( int numberOfDimensions, int basePopulationSize, int offspringPopulationSize, int numberOfGenerations, int seed = EvolutionDefaults.Seed, bool trackEvolutionSteps = EvolutionDefaults.TrackEvolutionSteps, bool useRedundantConstraintsRemoving = Defaults.UseRedundantConstraintsRemoving, bool useDataNormalization = Defaults.UseDataNormalization, bool allowQuadraticTerms = Defaults.AllowQuadraticTerms, bool useSeeding = Defaults.UseSeeding, ISet <TermType> allowedTermsTypes = default(ISet <TermType>), BenchmarkType typeOfBenchmark = Defaults.TypeOfBenchmark, double ballnBoundaryValue = Defaults.BallnBoundaryValue, double cubenBoundaryValue = Defaults.CubenBoundaryValue, double simplexnBoundaryValue = Defaults.SimplexnBoundaryValue, IList <Constraint> referenceConstraints = default(IList <Constraint>), long numberOfDomainSamples = Defaults.NumberOfDomainSamples, int numberOfTestPoints = Defaults.NumberOfTestPoints, int numberOfPositivePoints = Defaults.NumberOfPositivePoints, int numberOfNegativePoints = Defaults.NumberOfNegativePoints, double defaultDomainLowerLimit = Defaults.DefaultDomainLowerLimit, double defaultDomainUpperLimit = Defaults.DefaultDomainUpperLimit, int maxNumberOfPointsInSingleArray = Defaults.MaxNumberOfPointsInSingleArray, double globalLearningRate = double.NaN, double individualLearningRate = double.NaN, double stepThreshold = EvolutionDefaults.StepThreshold, double rotationAngle = EvolutionDefaults.RotationAngle, MutationType typeOfMutation = EvolutionDefaults.TypeOfMutation, int numberOfParentsSolutionsToSelect = EvolutionDefaults.NumberOfParentsSolutionsToSelect, ParentsSelectionType typeOfParentsSelection = EvolutionDefaults.TypeOfParentsSelection, SurvivorsSelectionType typeOfSurvivorsSelection = EvolutionDefaults.TypeOfSurvivorsSelection, int oneFifthRuleCheckInterval = EvolutionDefaults.OneFifthRuleCheckInterval, double oneFifthRuleScalingFactor = EvolutionDefaults.OneFifthRuleScalingFactor, bool useRecombination = EvolutionDefaults.UseRecombination, RecombinationType typeOfObjectsRecombination = EvolutionDefaults.TypeOfObjectsRecombination, RecombinationType typeOfStdDeviationsRecombination = EvolutionDefaults.TypeOfStdDeviationsRecombination, RecombinationType typeOfRotationsRecombination = EvolutionDefaults.TypeOfRotationsRecombination) { if (typeOfBenchmark == BenchmarkType.Other && referenceConstraints == default(IList <Constraint>)) { throw new ArgumentException("In case of choosing BenchmarkType = Other, it is obligatory to provide reference constraints."); } AllowedTermsTypes = allowedTermsTypes == default(ISet <TermType>) ? Defaults.AllowedTermsTypes : allowedTermsTypes; //HACK //AllowedTermsTypes = new HashSet<TermType> //{ // TermType.Linear, // TermType.Quadratic //}; //NumberOfConstraintsCoefficients = numberOfDimensions * AllowedTermsTypes.Count + 1; NumberOfConstraintsCoefficients = typeOfBenchmark == BenchmarkType.Balln && allowQuadraticTerms ? numberOfDimensions * 2 + 1 : numberOfDimensions + 1; //MaximumNumberOfConstraints = typeOfBenchmark == BenchmarkType.Other // // ReSharper disable once PossibleNullReferenceException : It is checked before // ? referenceConstraints.Count // : GetMaximumNumberOfConstraints(numberOfDimensions, typeOfBenchmark, allowQuadraticTerms); //MaximumNumberOfConstraints = GetMaximumNumberOfConstraints(numberOfDimensions, typeOfBenchmark, // allowQuadraticTerms); MaximumNumberOfConstraints = numberOfDimensions * numberOfDimensions; var objectVectorSize = NumberOfConstraintsCoefficients * MaximumNumberOfConstraints; NumberOfDimensions = numberOfDimensions; EvolutionParameters = new EvolutionParameters( objectVectorSize, basePopulationSize, offspringPopulationSize, numberOfGenerations, seed, trackEvolutionSteps, oneFifthRuleCheckInterval, oneFifthRuleScalingFactor, numberOfParentsSolutionsToSelect, (int)typeOfParentsSelection, (int)typeOfSurvivorsSelection, globalLearningRate, individualLearningRate, stepThreshold, rotationAngle, (int)typeOfMutation, useRecombination, (int)typeOfObjectsRecombination, (int)typeOfStdDeviationsRecombination, (int)typeOfRotationsRecombination); Seed = seed; TrackEvolutionSteps = trackEvolutionSteps; UseRedundantConstraintsRemoving = useRedundantConstraintsRemoving; UseDataNormalization = useDataNormalization; AllowQuadraticTerms = allowQuadraticTerms; UseSeeding = useSeeding; TypeOfBenchmark = typeOfBenchmark; BallnBoundaryValue = ballnBoundaryValue; CubenBoundaryValue = cubenBoundaryValue; SimplexnBoundaryValue = simplexnBoundaryValue; ReferenceConstraints = referenceConstraints; NumberOfDomainSamples = numberOfDomainSamples; NumberOfTestPoints = numberOfTestPoints; NumberOfPositivePoints = numberOfPositivePoints; NumberOfNegativePoints = numberOfNegativePoints; DefaultDomainLowerLimit = defaultDomainLowerLimit; DefaultDomainUpperLimit = defaultDomainUpperLimit; MaxNumberOfPointsInSingleArray = maxNumberOfPointsInSingleArray; }
/// <summary> /// Defines the parental haplotypes according to the recombination type /// </summary> /// <param name="recType"></param> public void DefineParentalHaplotypes(RecombinationType experimentDesign = RecombinationType.Backcross, double strengthOfNoise = 0.2) { /* * mother = new Individ(); * father = new Individ(); * Random s_Random = new Random(); * switch (experimentDesign) * { * case RecombinationType.Backcross: * for (int i = 0; i < mother.Haplotype0.Length; i++) * { * mother.Haplotype0[i] = 0; * mother.Haplotype1[i] = 1; * } * for (int i = 0; i < father.Haplotype0.Length; i++) * { * father.Haplotype0[i] = 1; * father.Haplotype1[i] = 1; * } * break; * * case RecombinationType.BackcrossWithNoise: * * for (int i = 0; i < mother.Haplotype0.Length; i++) * { * * if (s_Random.NextDouble() < strengthOfNoise) * { * mother.Haplotype0[i] = 1; * } * else * { * mother.Haplotype0[i] = 0; * } * * if (s_Random.NextDouble() < strengthOfNoise) * { * mother.Haplotype1[i] = 0; * } * else * { * mother.Haplotype1[i] = 1; * } * * } * for (int i = 0; i < father.Haplotype0.Length; i++) * { * if (s_Random.NextDouble() < strengthOfNoise) * { * father.Haplotype0[i] = 0; * } * else * { * father.Haplotype0[i] = 1; * } * if (s_Random.NextDouble() < strengthOfNoise) * { * father.Haplotype1[i] = 0; * } * else * { * father.Haplotype1[i] = 1; * } * * } * * * break; * } */ }