Exemplo n.º 1
0
 public RealRandomSearch(IEvaluation <double, double> evaluation, IStopCondition 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;
 }
Exemplo n.º 3
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);
 }
 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);
 }
Exemplo n.º 5
0
 public GeneticAlgorithm(IEvaluation <Element, Tuple <double, double> > evaluation, IStopCondition stopCondition,
                         AGenerator <Element> generator, ASelection <Tuple <double, double> > selection, ACrossover crossover,
                         IMutation <Element> mutation, int populationSize, int?seed = null)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize,
            new OptimizationState <Element>(evaluation.tMaxValue, evaluation.lOptimalParetoFront), seed)
 {
 }
 public ClusteringGeneticAlgorithm(IEvaluation <Element, Tuple <double, double> > evaluation, IStopCondition stopCondition,
                                   AGenerator <Element> generator, ASelection <Tuple <double, double> > selection, ACrossover crossover,
                                   IMutation <Element> mutation, int populationSize, int clusters, int?seed = null)
     : base(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize, seed)
 {
     no_clusters = clusters;
     rng         = seed.HasValue ? new Random(seed.Value) : new Random();
 }
 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();
 }
Exemplo n.º 8
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> >();
        }
Exemplo n.º 9
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;
        }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
 protected virtual Node_Generator parseGenerator(AGenerator node)
 {
     return new Node_Generator(
     parseOne<PExpression,INode_Expression>(parseExpression, (PExpression)node.GetType()),
     parseOne<PExpression,INode_Expression>(parseExpression, (PExpression)node.GetBody()),
     getSource(node));
 }
 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)
 {
 }
Exemplo n.º 13
0
        public GeneticAlgorithm(IEvaluation <Element, EvaluationResult> evaluation, IStopCondition stopCondition, AGenerator <Element> generator,
                                ASelection <EvaluationResult> selection, ACrossover crossover, IMutation <Element> mutation, int populationSize,
                                AOptimizationState <Element, EvaluationResult, OptimizationResult> state, int?seed = null)
            : base(evaluation, stopCondition, generator, selection, mutation, populationSize, state)
        {
            this.crossover = crossover;

            indices  = Utils.CreateIndexList(populationSize);
            shuffler = new Shuffler(seed);
        }
Exemplo n.º 14
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");
     }
 }
Exemplo n.º 15
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;
 }
Exemplo n.º 16
0
 public NSGA2(IEvaluation <Element, Tuple <double, double> > evaluation, IStopCondition stopCondition, AGenerator <Element> generator,
              IDominationComparer dominationComparer, ACrossover crossover, IMutation <Element> mutation, int populationSize,
              int?seed = null)
     : base(evaluation, stopCondition, generator, new NSGA2Selection(2, evaluation.tMaxValue, dominationComparer, true, seed),
            crossover, mutation, populationSize, seed)
 {
 }
 public GAWithDSM(IEvaluation <bool> evaluation, AStopCondition stopCondition, AGenerator <bool> generator,
                  ASelection selection, IMutation <bool> mutation, int populationSize,
                  double crossProb, double threshold)
     : base(evaluation, stopCondition, generator, selection, new DSMCrossover(crossProb, threshold, null), mutation, populationSize)
 {
 }
Exemplo n.º 18
0
 public SamplingOptimizer(IEvaluation <Element> evaluation, AStopCondition stopCondition, AGenerator <Element> generator)
     : base(evaluation, stopCondition)
 {
     this.generator = generator;
 }
Exemplo n.º 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;
     }
 }
 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;
 }
Exemplo n.º 21
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();
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
 public SamplingOptimizer(IEvaluation <Element, double> evaluation, IStopCondition stopCondition, AGenerator <Element> generator)
     : base(evaluation, stopCondition, new OptimizationState <Element>(evaluation.tMaxValue))
 {
     this.generator = generator;
 }
Exemplo n.º 24
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();
 }