public GeneticAlgorithm(ProblemBase problem, int initialPopulationSize, int numberOfGenerations)
 {
     this.Problem = problem;
     this.InitialPopulationSize = initialPopulationSize;
     this.NumberOfGenerations   = numberOfGenerations;
     EvaluateObjectiveValues();
 }
 public GeneticAlgorithm(ProblemBase problem, int initialPopulationSize, int numberOfGenerations)
 {
     this.Problem = problem;
     this.InitialPopulationSize = initialPopulationSize;
     this.NumberOfGenerations = numberOfGenerations;
     EvaluateObjectiveValues();
 }
 public IndividualBase(ProblemBase problem)
 {
     this.Problem = problem;
     this.ObjectivesValuesForMaximization  = new List <double>();
     this.ObjectivesValuesForNormalization = new List <double>();
     this.DominatesList = new List <IndividualBase>();
     this.DistancesToOtherIndividuals = new List <Tuple <IndividualBase, double> >();
 }
 public IndividualBase(ProblemBase problem)
 {
     this.Problem = problem;
     this.ObjectivesValuesForMaximization = new List<double>();
     this.ObjectivesValuesForNormalization = new List<double>();
     this.DominatesList = new List<IndividualBase>();
     this.DistancesToOtherIndividuals = new List<Tuple<IndividualBase, double>>();
 }
 public NSGA2(ProblemBase problem,
     //SelectionMethodBase selectionMethod,
     //CrossoverMethodBase crossoverMethod,
     //ReinsertionMethodBase reinsertionMethod,
     int populationSize, int offspringPopSize, int numberOfGenerations, int mutationPct)
     : base(problem, populationSize, numberOfGenerations, mutationPct)
 {
     this.offspringPopSize = offspringPopSize;
 }
 /// <summary>
 /// Represents an Entity able to execute the Genetic Algorithm for the input parameters
 /// </summary>
 /// <param name="problem">Instance of a Problem to be Solved</param>
 /// <param name="selectionMethodType">The Method to Be used for Parent Selection in Crossover Methods</param>
 /// <param name="tourSize">In case the 'Tour' Method is chosen as the current Selection Method, this parameter will be considered in its evaluation</param>
 /// <param name="crossoverMethodType">The Method to be used for Crossover between two parents</param>
 /// <param name="reinsertionMethodType">The Method by which Individuals are chosen to be part of the next Generation</param>
 /// <param name="populationSize">The Individual Count in a Population that is considered to be a Generation</param>
 /// <param name="numberOfGenerations">The Number of Generations to run before the algorithm returns an Result</param>
 /// <param name="crossoverPct">The Crossover percentage involved in the calculation</param>
 /// <param name="mutationPct">The Mutation percentage involved in the calculation</param>
 public MonoObjectiveGeneticAlgorithm(ProblemBase problem, SelectionMethodBase selectionMethod, CrossoverMethodBase crossoverMethod, ReinsertionMethodBase reinsertionMethod, int populationSize, int numberOfGenerations, int mutationPct)
     : base(problem, populationSize, numberOfGenerations)
 {
     this.mutationPct = mutationPct;
     this.selectionMethod = selectionMethod;
     selectionMethod.Problem = problem;
     this.crossoverMethod = crossoverMethod;
     crossoverMethod.Problem = problem;
     this.reinsertionMethod = reinsertionMethod;
 }
        public static void Execute(IndividualBase individual, ProblemBase problem)
        {
            problem.EvaluateIndividual(individual);

            if(!individual.WasEvaluated) {
                individual.ObjectivesValuesForMaximization.Add(double.MaxValue);
                individual.ObjectivesValuesForNormalization.Add(double.MaxValue);
            }

            Objective objective = problem.MonoObjectiveGoal;
            individual.SetFitnessForObjective(objective);
            individual.WasEvaluated = true;
        }
 private static List<IndividualBase> MonoObjectiveGeneticAlgorithmTest(ProblemBase mainProblem, string convergenceReport)
 {
     MonoObjectiveGeneticAlgorithm AG = new MonoObjectiveGeneticAlgorithm(
         mainProblem,
         new Tour(3),
         new Ciclic(),
         new BestAmongstAll(100),
         200,
         200,
         30);
     List<IndividualBase> retorno = new List<IndividualBase>();
     retorno.Add(AG.Execute());
     return retorno;
 }
 //SelectionMethodBase selectionMethod;
 //CrossoverMethodBase crossoverMethod;
 //ReinsertionMethodBase reinsertionMethod;
 /// <summary>
 /// Represents an Entity able to execute the Genetic Algorithm for the input parameters
 /// </summary>
 /// <param name="problem">Instance of a Problem to be Solved</param>
 /// <param name="selectionMethodType">The Method to Be used for Parent Selection in Crossover Methods</param>
 /// <param name="tourSize">In case the 'Tour' Method is chosen as the current Selection Method, this parameter will be considered in its evaluation</param>
 /// <param name="crossoverMethodType">The Method to be used for Crossover between two parents</param>
 /// <param name="reinsertionMethodType">The Method by which Individuals are chosen to be part of the next Generation</param>
 /// <param name="populationSize">The Individual Count in a Population that is considered to be a Generation</param>
 /// <param name="numberOfGenerations">The Number of Generations to run before the algorithm returns an Result</param>
 /// <param name="crossoverPct">The Crossover percentage involved in the calculation</param>
 /// <param name="mutationPct">The Mutation percentage involved in the calculation</param>
 public MultiObjectiveGeneticAlgorithm(ProblemBase problem,
     //SelectionMethodBase selectionMethod,
     //CrossoverMethodBase crossoverMethod,
     //ReinsertionMethodBase reinsertionMethod,
     int populationSize, int numberOfGenerations, int mutationPct)
     : base(problem, populationSize, numberOfGenerations)
 {
     this.InitialPopulationSize = populationSize;
     this.Problem = problem;
     this.NumberOfGenerations = numberOfGenerations;
     this.mutationPct = mutationPct;
     //this.selectionMethod = selectionMethod;
     //selectionMethod.Problem = problem;
     //this.crossoverMethod = crossoverMethod;
     //crossoverMethod.Problem = problem;
     //this.reinsertionMethod = reinsertionMethod;
 }
Esempio n. 10
0
        public static void Execute(IndividualBase individual, ProblemBase problem)
        {
            problem.EvaluateIndividual(individual);

            if (!individual.WasEvaluated)
            {
                foreach (Objective objective in problem.MultiObjectiveGoal)
                {
                    individual.ObjectivesValuesForMaximization.Add(double.MaxValue);
                    individual.ObjectivesValuesForNormalization.Add(double.MaxValue);
                }
            }

            foreach (Objective objective in problem.MultiObjectiveGoal)
            {
                individual.SetFitnessForObjective(objective);
            }

            individual.WasEvaluated = true;
        }
 public EstocasticTour(ProblemBase problem, int tourSize)
 {
     this.problem = problem;
     this.tourSize = tourSize;
 }
 private static List<IndividualBase> MonoObjectiveGeneticAlgorithmTest(ProblemBase mainProblem, out string convergenceReport)
 {
     MonoObjectiveGeneticAlgorithm AG = new MonoObjectiveGeneticAlgorithm(
         mainProblem,
         new Tour(1),
         new PMX(),
         new Elitist(30),
         200,
         200,
         15);
     List<IndividualBase> retorno = new List<IndividualBase>();
     retorno.Add(AG.Execute(100, out convergenceReport));
     return retorno;
 }
        private static IEnumerable<IndividualBase> SPEA2MultiExecution(int executionCount, ProblemBase problem, int populationSize)
        {
            MultiObjectiveGeneticAlgorithm SPEA2 = new NSGA2(
               problem,
               populationSize,
               200,
               200,
               10);

            Population_MultiObjective_AG Aggregator = new Population_MultiObjective_AG(problem);

            for (int i = 0; i < executionCount; ++i) {
                IEnumerable<IndividualBase> executionResult = SPEA2.Execute();
                Aggregator.AddRange(executionResult);
            }

            IEnumerable<IndividualBase> nonDominatedFront = Aggregator.FastNonDominatedSort().First().Content;
            IEnumerable<IndividualBase> firstItemsByMakeSpan = (from i in nonDominatedFront.Cast<TaskSchedulingSolution>()
                                                                group i by i.MakeSpan into g
                                                                select g.First()).OrderBy(I => I.MakeSpan);

            return firstItemsByMakeSpan;
        }
 public Population_MonoObjective_AG(ProblemBase problem, int populationSize)
     : base(populationSize)
 {
     this.problem = problem;
 }
 public Population_MultiObjective_AG(ProblemBase problem)
     : base(int.MaxValue)
 {
     this.Problem = problem;
 }
 public Roulette(ProblemBase problem)
 {
     this.problem = problem;
 }
 public SPEA2(ProblemBase problem, int populationSize, int archivePopSize, int numberOfGenerations, int mutationPct)
     : base(problem, populationSize, numberOfGenerations, mutationPct)
 {
     this.ArchivePopulationSize = archivePopSize;
 }
        private static IEnumerable<IndividualBase> SPEA2Test(ProblemBase mainProblem)
        {
            MultiObjectiveGeneticAlgorithm SPEA2 = new SPEA2(
               mainProblem,
               200,
               200,
               400,
               10);

            return SPEA2.Execute();
        }