public TaskSchedulingSolution(ProblemBase problem, int[,] geneticMaterial)
            : base(problem)
        {
            TaskSchedulingProblem schedulingProblem = (Problem as TaskSchedulingProblem);

            this.GeneticMaterial = geneticMaterial;
        }
 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;
 }
Beispiel #4
0
        private static IEnumerable <IndividualBase> NSGA2Test(ProblemBase mainProblem)
        {
            MultiObjectiveGeneticAlgorithm NSGA2 = new NSGA2(
                mainProblem,
                200,
                200,
                400,
                2);

            return(NSGA2.Execute());
        }
        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;
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
        public TaskSchedulingSolution(ProblemBase problem)
            : base(problem)
        {
            TaskSchedulingProblem schedulingProblem = (Problem as TaskSchedulingProblem);

            this.GeneticMaterial = new int[2, schedulingProblem.TaskCount];

            IEnumerable<int> randomTaskPermutation = Aleatoriety.GetRandomIntegerSequencePermutation(0, schedulingProblem.TaskCount);

            int idx = 0;
            foreach (int task in randomTaskPermutation) {
                this.GeneticMaterial[0, idx] = task;
                this.GeneticMaterial[1, idx] = Aleatoriety.GetRandomInt(schedulingProblem.ProcessorCount);
                ++idx;
            }
        }
        //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;
        }
        public TaskSchedulingSolution(ProblemBase problem) : base(problem)
        {
            TaskSchedulingProblem schedulingProblem = (Problem as TaskSchedulingProblem);

            this.GeneticMaterial = new int[2, schedulingProblem.TaskCount];

            IEnumerable <int> randomTaskPermutation = Aleatoriety.GetRandomIntegerSequencePermutation(0, schedulingProblem.TaskCount);

            int idx = 0;

            foreach (int task in randomTaskPermutation)
            {
                this.GeneticMaterial[0, idx] = task;
                this.GeneticMaterial[1, idx] = Aleatoriety.GetRandomInt(schedulingProblem.ProcessorCount);
                ++idx;
            }
        }
Beispiel #11
0
        /// <summary>
        /// Creates the concrete instance of the Problem type.
        /// </summary>
        /// <param name="currentProblem">
        /// Problem type to create.
        /// </param>
        /// <returns>
        /// The Problem's instance.
        /// </returns>
        internal static ProblemBase CreateProblem(ProblemFamily currentProblem)
        {
            ProblemBase problem = default;

            switch (currentProblem)
            {
            case ProblemFamily.None:
                break;

            case ProblemFamily.TravellingSalesmanProblem:
                // TODO... Creation of "Travelling Salesman problem"
                break;

            case ProblemFamily.VehicleRoutingProblem:
                // TODO... Creation of "Vehicle Routing problem"
                break;

            case ProblemFamily.TeamOrienteering:
                problem = new ToProblem();
                break;
            }
            return(problem);
        }
Beispiel #12
0
 /// <summary>
 /// Defines a Sap2000 Model.
 /// </summary>
 /// <param name="inModelFolder">The target folder for the analysis</param>
 public S2KModel(string inModelFolder, ProblemBase inProblem) : base(inModelFolder, "model.s2k", inProblem)
 {
 }
Beispiel #13
0
 public SPEA2(ProblemBase problem, int populationSize, int archivePopSize, int numberOfGenerations, int mutationPct)
     : base(problem, populationSize, numberOfGenerations, mutationPct)
 {
     this.ArchivePopulationSize = archivePopSize;
 }
 public Population_MultiObjective_AG(ProblemBase problem)
     : base(int.MaxValue)
 {
     this.Problem = problem;
 }
 public Population_MultiObjective_AG(ProblemBase problem, int populationSize) : base(populationSize)
 {
     this.Problem = problem;
 }
 public CryptArithmeticSolution(ProblemBase problem, int[] lettersValues)
     : base(problem)
 {
     this.LettersValues = lettersValues;
 }
 public CryptArithmeticSolution(ProblemBase problem)
     : base(problem)
 {
     int amountOfChars = Enumerable.Range(0, 10).Count();
     LettersValues = Aleatoriety.GetRandomIntegerSequencePermutation(0, amountOfChars).ToArray();
 }
 public CryptArithmeticSolution(ProblemBase problem, int[] lettersValues) : base(problem)
 {
     this.LettersValues = lettersValues;
 }
        public CryptArithmeticSolution(ProblemBase problem) : base(problem)
        {
            int amountOfChars = Enumerable.Range(0, 10).Count();

            LettersValues = Aleatoriety.GetRandomIntegerSequencePermutation(0, amountOfChars).ToArray();
        }
        public TaskSchedulingSolution(ProblemBase problem, int[,] geneticMaterial) : base(problem)
        {
            TaskSchedulingProblem schedulingProblem = (Problem as TaskSchedulingProblem);

            this.GeneticMaterial = geneticMaterial;
        }
 public EstocasticTour(ProblemBase problem, int tourSize)
 {
     this.problem  = problem;
     this.tourSize = tourSize;
 }
Beispiel #22
0
        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 Roulette(ProblemBase problem)
 {
     this.problem = problem;
 }