示例#1
0
文件: QAPTester.cs 项目: jswk/GA-BO
        // results in "qap/results/testName"
        public void test(string testName)
        {
            QAPProblem problem = problemFromFile(testName);

            //configuration
            GlobalConfiguration globalConfig = new GlobalConfiguration(){maximize = false};
            globalConfig.configurations = new List<IslandConfiguration>();
            globalConfig.configurations.Add(new IslandConfiguration(algorithm.enums.EvolutionStrategy.Tournament, 0.01, 0.1, 20, 10, 1));
            globalConfig.configurations.Add(new IslandConfiguration(algorithm.enums.EvolutionStrategy.Tournament, 0.02, 0.05, 30, 10, 1));
            globalConfig.configurations.Add(new IslandConfiguration(algorithm.enums.EvolutionStrategy.Tournament, 0.05, 0.02, 20, 10, 1));
            globalConfig.configurations.Add(new IslandConfiguration(algorithm.enums.EvolutionStrategy.Tournament, 0.1, 0.01, 30, 10, 1));
            globalConfig.connections = new List<int>[globalConfig.configurations.Count];
            for(int i=0;i<globalConfig.configurations.Count;i++)
                globalConfig.connections[i] = new List<int>();
            //globalConfig.connections[0].Add(3);
            //globalConfig.connections[1].Add(3);
            //globalConfig.connections[2].Add(3);
            globalConfig.evolutionTimeInSeconds = 25;
            globalConfig.generator = new QAPGenerator(problem);

            IslandSupervisor supervisor = new IslandSupervisor(globalConfig);
            QAPIndividual result =(QAPIndividual) supervisor.getResult();
            foreach(int i in result.permutation)
                Console.WriteLine(i.ToString() + " ");
            //int result = 5;
            saveResult(result.value(), testName);
        }
示例#2
0
文件: Island.cs 项目: jswk/GA-BO
 public Island(IFactory factory, IslandConfiguration configuration,IslandSupervisor supervisor)
 {
     this.islandThread = new Thread(new ThreadStart(run)); //http://stackoverflow.com/questions/1923512/threading-does-c-sharp-have-an-equivalent-of-the-java-runnable-interface
     this.factory = factory;
     this.configuration = configuration;
     this.supervisor = supervisor;
     this.arrivingIndividuals = new ConcurrentQueue<IIndividual>();
     Console.WriteLine("Island created");
 }
示例#3
0
文件: Island.cs 项目: jswk/GA-BO
 public Island(IFactory factory, IslandConfiguration configuration, IslandSupervisor supervisor)
 {
     this.islandThread        = new Thread(new ThreadStart(run)); //http://stackoverflow.com/questions/1923512/threading-does-c-sharp-have-an-equivalent-of-the-java-runnable-interface
     this.factory             = factory;
     this.configuration       = configuration;
     this.supervisor          = supervisor;
     this.arrivingIndividuals = new ConcurrentQueue <IIndividual>();
     Console.WriteLine("Island created");
 }