Esempio n. 1
0
        void InitializeGa()
        {
            TspLibDocument doc = new TspLibDocument("../../../TravellingSalesman/xpf131.tsp");

//            TspLibDocument doc = new TspLibDocument("../../../TravellingSalesman/xit1083.tsp");
            //TspLibDocument doc = new TspLibDocument("../../../TravellingSalesman/tspbayg29.tsp");
            cities = doc.cities;
            maxX   = doc.maxX;
            maxY   = doc.maxY;

            Ga = new GA();
            //Ga.GeneDescriptors = new GeneDescriptor[] { new IntegerGeneDescriptor() };
            Ga.GeneDescriptors  = new GeneDescriptor[] { new DoubleGeneDescriptor() };
            Ga.Homogeneous      = true;
            Ga.ChromosomeLength = cities.Length;

            Ga.Recombinator = new RecombinationDelegate(new genX.Recombination.PartiallyMatchedCrossover().Recombine);
            //Ga.OrderMutator = new OrderMutationDelegate( genX.Reordering.Swap.Reorder );
            Ga.OrderMutator = new OrderMutationDelegate(genX.Reordering.Inversion.Reorder);
            Ga.ValueMutator = new ValueMutationDelegate(genX.Mutation.BitwiseMutation.Mutate);
            Ga.Scaler       = new ScalingDelegate(new genX.Scaling.LinearRankedFitnessScaler(2.5).Scale);

            Ga.RecombinationProbability = 0.8;
            Ga.OrderMutationProbability = 0.15;

            Ga.PopulationSize = 500;
            Ga.Objective      = new ObjectiveDelegate(GetObjective);
            Ga.ObjectiveType  = ObjectiveType.MinimizeObjective;
            Ga.MaxGenerations = 1000000;

            Ga.NewPopulation += new NewPopulationEventHandler(OnNewPopulation);

            t = new System.Threading.Thread(new System.Threading.ThreadStart(gaThread));
            t.Start();
        }
Esempio n. 2
0
        void InitializeGa()
        {        
            TspLibDocument doc = new TspLibDocument("../../../TravellingSalesman/xpf131.tsp");
//            TspLibDocument doc = new TspLibDocument("../../../TravellingSalesman/xit1083.tsp");
            //TspLibDocument doc = new TspLibDocument("../../../TravellingSalesman/tspbayg29.tsp");
            cities = doc.cities;
            maxX = doc.maxX;
            maxY = doc.maxY;

            Ga = new GA();
            //Ga.GeneDescriptors = new GeneDescriptor[] { new IntegerGeneDescriptor() };
            Ga.GeneDescriptors = new GeneDescriptor[] { new DoubleGeneDescriptor() };
            Ga.Homogeneous = true;
            Ga.ChromosomeLength = cities.Length;            

            Ga.Recombinator = new RecombinationDelegate( new genX.Recombination.PartiallyMatchedCrossover().Recombine );
            //Ga.OrderMutator = new OrderMutationDelegate( genX.Reordering.Swap.Reorder );
            Ga.OrderMutator = new OrderMutationDelegate( genX.Reordering.Inversion.Reorder );
            Ga.ValueMutator = new ValueMutationDelegate( genX.Mutation.BitwiseMutation.Mutate );
            Ga.Scaler = new ScalingDelegate( new genX.Scaling.LinearRankedFitnessScaler(2.5).Scale );

            Ga.RecombinationProbability = 0.8;
            Ga.OrderMutationProbability = 0.15;

            Ga.PopulationSize       = 500;
            Ga.Objective            = new ObjectiveDelegate( GetObjective );
            Ga.ObjectiveType        = ObjectiveType.MinimizeObjective;
            Ga.MaxGenerations       = 1000000;

            Ga.NewPopulation += new NewPopulationEventHandler( OnNewPopulation );

            t = new System.Threading.Thread( new System.Threading.ThreadStart( gaThread ) );
            t.Start();            
        }