Example #1
0
        /**
         * In DOVS, we provide the algorithm with a start individual from file, this
         * start individual is the start search point of the DOVS algorithm. We use
         * this start point to construct a hyperbox contains promising solutions,
         * and sample from this region, the number of sample is equal to parameter
         * "pop.subpop.X.size" in parameter files.
         *
         * However, due to redundant samples, we the individuals size may be
         * smaller than what have been specified in pop.subpop.X.size.
         */
        public override Population InitialPopulation(IEvolutionState state, int thread)
        {
            Population p = base.InitialPopulation(state, thread);

            // make sure the each subpop only have one individual
            for (int i = 0; i < p.Subpops.Count; i++)
            {
                if (p.Subpops[i].Species is DOVSSpecies)
                {
                    DOVSSpecies species = (DOVSSpecies)p.Subpops[i].Species;

                    if (p.Subpops[i].Individuals.Count != 1)
                    {
                        state.Output.Fatal("contain more than one start point");
                    }

                    // add the start point to the visited ArrayList
                    species.Visited.Clear();
                    species.Visited.Add(p.Subpops[i].Individuals[0]);
                    species.VisitedIndexMap[p.Subpops[i].Individuals[0]] = 0;
                    species.OptimalIndex = 0;

                    IntegerVectorIndividual ind = (IntegerVectorIndividual)species.Visited[species.OptimalIndex];
                    // For the visited solution, record its coordinate
                    // positions in the multimap
                    for (int j = 0; j < species.GenomeSize; ++j)
                    {
                        // The individual is the content. The key is its
                        // coordinate position
                        species.Corners[j].Insert(ind.genome[j], ind);
                    }

                    // update MPA
                    species.UpdateMostPromisingArea(state);

                    // sample from MPA
                    int initialSize = p.Subpops[i].InitialSize;
                    IList <Individual> candidates = species.MostPromisingAreaSamples(state, initialSize);

                    // get unique candidates for evaluation, this is Sk in paper
                    IList <Individual> uniqueCandidates = species.UniqueSamples(state, candidates);

                    // update the individuals
                    p.Subpops[i].Individuals = uniqueCandidates;
                }
            }
            return(p);
        }
Example #2
0
        /**
         * This method have three major part, first identify the best indiviudal,
         * and then call updateMostPromisingArea(...) to construct a hyperbox around
         * this individual. At last, sampled a new population from the hyperbox and
         * take the none redundant samples and return it.
         */

        public override Population BreedPopulation(IEvolutionState state)
        {
            Population pop = state.Population;

            for (int i = 0; i < pop.Subpops.Count; i++)
            {
                Subpopulation subpop = pop.Subpops[i];
                if (!(subpop.Species is DOVSSpecies)) // uh oh
                {
                    state.Output.Fatal("To use DOVSBreeder, subpopulation " + i
                                       + " must contain a DOVSSpecies.  But it contains a " + subpop.Species);
                }

                DOVSSpecies species = (DOVSSpecies)(subpop.Species);

                // we assume backTrackingTest is always false.
                // Thus we combine activeSolution and Sk (individuals) to
                // identify the optimal
                species.FindBestSample(state, subpop);

                // Right now activeSolutions only has A_{k-1}, need to combine S_k
                for (int j = 0; j < subpop.Individuals.Count; j++)
                {
                    species.ActiveSolutions.Add(subpop.Individuals[i]);
                }
                // Ak and bk will have all the constraints, including original
                // problem formulation and MPR
                // A b are original problem formulation constraints
                // activeSolutions will then have the indices for those solutions
                // already visited and define MPR
                // excluding current best solution

                // update MPA
                species.UpdateMostPromisingArea(state);

                // sample from MPA
                IList <Individual> candidates = species.MostPromisingAreaSamples(state, subpop.InitialSize);
                // get Sk for evaluation
                IList <Individual> Sk = species.UniqueSamples(state, candidates);

                // update the individuals
                subpop.Individuals = Sk;
            }
            return(pop);
        }