Example #1
0
 public RealRandomSearch(IEvaluation <double> evaluation, AStopCondition stopCondition, int?seed = null)
 {
     Result             = null;
     this.evaluation    = evaluation;
     this.stopCondition = stopCondition;
     generator          = new RealRandomGenerator(evaluation.pcConstraint, seed);
 }
 public ASimpleOptimizer(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGenerator <Element> generator)
 {
     Result             = null;
     this.evaluation    = evaluation;
     this.stopCondition = stopCondition;
     this.generator     = generator;
 }
Example #3
0
 public ResettingGA(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGenerator <Element> generator,
                    ASelection selection, ACrossover crossover, IMutation <Element> mutation, int populationSize, int patience, int?seed = null)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
 {
     this.patience = patience;
     rng           = seed.HasValue ? new Random(seed.Value) : new Random();
 }
 public GAStallDetection(IEvaluation<Element> evaluation, AStopCondition stopCondition, AGenerator<Element> generator,
                         ASelection selection, ACrossover crossover, IMutation<Element> mutation, int populationSize, 
                         int maxNoChangeDetections)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
 {
     MaxNCD = maxNoChangeDetections;
 }
Example #5
0
 public AOptimizer(IEvaluation <Element> evaluation, AStopCondition stopCondition)
 {
     Result                   = null;
     this.Evaluation          = evaluation;
     this.StopCondition       = stopCondition;
     this.divergenceException = false;
 }
Example #6
0
 public BinaryRandomSearch(IEvaluation <bool> evaluation, AStopCondition stopCondition, int?seed = null)
 {
     Result             = null;
     this.evaluation    = evaluation;
     this.stopCondition = stopCondition;
     generator          = new BinaryRandomGenerator(evaluation.pcConstraint, seed);
 }
Example #7
0
 public KnapsackGA(CBinaryKnapsackEvaluation evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                   ASelection selection, ACrossover crossover, IMutation <bool> mutation, int populationSize, EffectType effType, int?seed)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
 {
     this.seed  = seed;
     effectType = effType;
 }
Example #8
0
 public AOptimizer(AEvaluation <Element> evaluation, AStopCondition stopCondition)
 {
     Result             = null;
     this.Evaluation    = evaluation;
     this.StopCondition = stopCondition;
     bestSolutions      = new List <double>();
 }
 public BinaryGreedyRSOptimizer(IEvaluation <bool> evaluation, AStopCondition stopCondition,
                                AStopCondition greedyStopCondition, int?seed = null)
     : base(evaluation, stopCondition)
 {
     generator       = new BinaryRandomGenerator(evaluation.pcConstraint, seed);
     greedyOptimizer = new BinaryGreedyOptimizer(evaluation, null, greedyStopCondition, seed);
 }
Example #10
0
 public RealRestartingEvolutionStrategy11(IEvaluation <double> evaluation, AStopCondition stopCondition, ARealMutationES11Adaptation mutationAdaptation, int patience, int?seed = null)
     : base(evaluation, stopCondition)
 {
     this.mutationAdaptation = mutationAdaptation;
     randomGeneration        = new RealRandomGenerator(evaluation.pcConstraint, seed);
     this.patience           = patience;
 }
 public RealEvolutionStrategy11(IEvaluation <double> evaluation, AStopCondition stopCondition, ARealMutationES11Adaptation mutationAdaptation, int?seed = null)
 {
     Result                  = null;
     this.evaluation         = evaluation;
     this.stopCondition      = stopCondition;
     this.mutationAdaptation = mutationAdaptation;
     randomGeneration        = new RealRandomGenerator(evaluation.pcConstraint, seed);
 }
Example #12
0
        public KnapsackGeneticAlgorithm(CBinaryKnapsackEvaluation evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                                        ASelection selection, ACrossover crossover, IMutation <bool> mutation, int populationSize)
            : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
        {
            var emptySolution = Enumerable.Repeat(false, evaluation.iSize).ToList();

            CheckNewBest(emptySolution, 0.0, true);
        }
 public DSMGA(IEvaluation <bool> evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
              ASelection selection, ACrossover crossover, IMutation <bool> mutation, int populationSize)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
 {
     Combinations = GetKCombs(Enumerable.Range(0, evaluation.iSize), 2)
                    .Select(x => x.ToList()).ToList();
     ResetContingencyMatrixTable();
 }
Example #14
0
        public MutatedIslandGA(IEvaluation <bool> evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                               ASelection selection, ACrossover crossover, IMutation <bool> mutation, int populationSize)
            : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
        {
            var moreMutation = new BinaryBitFlipMutation(1, evaluation);
            int mutatedPop   = populationSize / 10 % 2 == 1 ? populationSize / 10 - 1 : populationSize / 10;

            mutatedPop   = mutatedPop == 0 ? 2 : mutatedPop;
            mutantIsland = new GeneticAlgorithm <bool>(evaluation, stopCondition, generator, selection, crossover, moreMutation, mutatedPop);
            mutantIsland.Initialize();
        }
Example #15
0
        public APopulationOptimizer(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGenerator <Element> generator,
                                    ASelection selection, IMutation <Element> mutation, int populationSize)
            : base(evaluation, stopCondition)
        {
            this.generator = generator;
            this.selection = selection;
            this.mutation  = mutation;

            this.populationSize = populationSize;
            population          = new List <Individual <Element> >();
        }
 public TspGreedy(TspEvaluation evaluation, AStopCondition stopCondition, int start)
     : base(evaluation, stopCondition)
 {
     if (start < evaluation.iSize)
     {
         startPosition = start;
     }
     else
     {
         throw new Exception("incorrect starting position");
     }
 }
Example #17
0
        public EncodedGA(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGenerator <Element> generator,
                         ASelection selection, ACrossover crossover, IMutation <Element> mutation, int populationSize, int?seed)
            : base(evaluation, stopCondition)
        {
            this.generator = generator;
            this.selection = selection;
            this.mutation  = mutation;

            this.populationSize = populationSize;
            population          = new List <EncodedIndividual <Element> >();
            this.seed           = seed;
            this.crossover      = crossover;
        }
Example #18
0
 public IslandModel(IEvaluation <bool> evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                    ASelection selection, ACrossover crossover, IMutation <bool> mutation,
                    int globalPopulationSize, int islandCount, int maxNoChangeDetections,
                    APopulationCrossover <bool> populationCrossover)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, 0)
 {
     this.islandCount          = islandCount;
     this.globalPopulationSize = globalPopulationSize;
     maxNoChangeDetections     = maxNoChangeDetections;
     this.populationCrossover  = populationCrossover;
     if (globalPopulationSize % islandCount != 0)
     {
         throw new Exception("liczba wysp jest nie podzielna przez wielkosc calej populacji");
     }
 }
Example #19
0
 public GAwithDSM(IEvaluation <bool> evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                  ASelection selection, ACrossover crossover, IMutation <bool> mutation, int populationSize, int interval = 10)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
 {
     this.interval = interval;
     dsms          = new List <List <List <double> > >();
     if (crossover is DSMCrossover)
     {
         List <List <double> > tempDSM = new List <List <double> >();
         for (int i = 0; i < evaluation.iSize; i++)
         {
             tempDSM.Add(Enumerable.Repeat(0.0, evaluation.iSize).ToList());
         }
         ((DSMCrossover)crossover).dsm = tempDSM;
     }
 }
Example #20
0
        public CMAES(IEvaluation <double> evaluation, AStopCondition stopCondition, double initSigma, int?seed = null)
            : base(evaluation, stopCondition)
        {
            this.initSigma = initSigma;

            normalRNG     = new NormalRealRandom(seed);
            realGenerator = new RealRandomGenerator(evaluation.pcConstraint, seed);

            int N = evaluation.iSize;

            previousMeans = Vector <double> .Build.Dense(N);

            means = Vector <double> .Build.Dense(N);

            covarianceMatrix = Matrix <double> .Build.Dense(N, N);

            selectionParameters  = new SelectionParameters(N);
            stepSizeParameters   = new StepSizeParameters(N, initSigma);
            adaptationParameters = new AdaptationParameters(N, selectionParameters);

            sampledPopulation = new List <Individual>(selectionParameters.Lambda);
        }
 public SamplingOptimizer(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGeneration <Element> generation)
     : base(evaluation, stopCondition)
 {
     this.generation = generation;
 }
 public BinaryGreedyOptimizer(IEvaluation <bool> evaluation, AStopCondition stopCondition = null, int?seed = null)
     : this(evaluation, null, stopCondition, seed)
 {
 }
 public BinaryGreedyOptimizer(IEvaluation <bool> evaluation, List <bool> solution, AStopCondition stopCondition = null, int?seed = null)
     : base(evaluation, stopCondition ?? new IterationsStopCondition(evaluation.dMaxValue, 1))
 {
     optimizedSolution = solution;
     if (seed == null)
     {
         shuffler = new Shuffler();
         rnd      = new Random();
     }
     else
     {
         shuffler = new Shuffler(seed.Value);
         rnd      = new Random(seed.Value);
     }
 }
Example #24
0
 public AOptimizer(IEvaluation <Element> evaluation, AStopCondition stopCondition)
 {
     Result             = null;
     this.evaluation    = evaluation;
     this.stopCondition = stopCondition;
 }
 public RealES11Scouting(IEvaluation <double> evaluation, AStopCondition stopCondition, ARealMutationES11Adaptation mutationAdaptation, int?seed)
     : this(evaluation, stopCondition, mutationAdaptation, seed, 10, 1.5)
 {
 }
Example #26
0
 public GeneticAlgorithm(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGenerator <Element> generator,
                         ASelection selection, ACrossover crossover, IMutation <Element> mutation, int populationSize)
     : base(evaluation, stopCondition, generator, selection, mutation, populationSize)
 {
     this.crossover = crossover;
 }
 public TspRandomSearch(TspEvaluation evaluation, AStopCondition stopCondition)
     : base(evaluation, stopCondition, new TspGenerator(new Random()))
 {
 }
 public RealES11Scouting(IEvaluation <double> evaluation, AStopCondition stopCondition, ARealMutationES11Adaptation mutationAdaptation, int?seed, int nScouts = 5, double scoutingMultiplier = 2)
     : base(evaluation, stopCondition, mutationAdaptation, seed)
 {
     this.nScouts            = nScouts;
     this.scoutingMultiplier = scoutingMultiplier;
 }
 public BaldwinGeneticAlgorithm(CBinaryKnapsackEvaluation evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                                ASelection selection, ACrossover crossover, IMutation <bool> mutation, int populationSize)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize)
 {
 }
Example #30
0
 public BinaryRandomSearch(IEvaluation <bool> evaluation, AStopCondition stopCondition, int?seed = null)
     : base(evaluation, stopCondition, new BinaryRandomGenerator(evaluation.pcConstraint, seed))
 {
 }