Exemple #1
0
        public IslandSupervisor(GlobalConfiguration configuration)
        {
            this.configuration = configuration;
            this.islands       = new Island[configuration.configurations.Count];
            int i = 0;

            //create islands
            foreach (IslandConfiguration islandConfiguration in configuration.configurations)
            {
                IFactory factory = null;
                switch (islandConfiguration.evolutionStrategy)
                {
                case EvolutionStrategy.Roulette:
                    factory = new RouletteFactory(configuration, islandConfiguration);
                    break;

                case EvolutionStrategy.Stochastic:
                    factory = new StochasticFactory(configuration, islandConfiguration);
                    break;

                case EvolutionStrategy.Tournament:
                    factory = new TournamentFactory(configuration, islandConfiguration);
                    break;

                case EvolutionStrategy.LinearRanked:
                    factory = new LinearRankedFactory(configuration, islandConfiguration);
                    break;

                case EvolutionStrategy.Truncation:
                    factory = new TruncationFactory(configuration, islandConfiguration);
                    break;

                default:
                    throw new MissingMemberException("Undefined factory for selected strategy!");
                }
                this.islands[i++] = new Island(factory, islandConfiguration, this);
            }
            Console.WriteLine("All islands initialized");
            //create connections
            this.connections = new IslandConnections(configuration.connections, this.islands);
            Console.WriteLine("Connections created");
            Console.WriteLine("Supervisor created");
        }
Exemple #2
0
        public IslandSupervisor(GlobalConfiguration configuration)
        {
            this.configuration=configuration;
            this.islands = new Island[configuration.configurations.Count];
            int i=0;

            //create islands
            foreach(IslandConfiguration islandConfiguration in configuration.configurations)
            {
                IFactory factory=null;
                switch(islandConfiguration.evolutionStrategy)
                {
                    case EvolutionStrategy.Roulette:
                        factory=new RouletteFactory(configuration,islandConfiguration);
                        break;
                    case EvolutionStrategy.Stochastic:
                        factory = new StochasticFactory(configuration, islandConfiguration);
                        break;
                    case EvolutionStrategy.Tournament:
                        factory = new TournamentFactory(configuration, islandConfiguration);
                        break;
                    case EvolutionStrategy.LinearRanked:
                        factory = new LinearRankedFactory(configuration, islandConfiguration);
                        break;
                    case EvolutionStrategy.Truncation:
                        factory = new TruncationFactory(configuration, islandConfiguration);
                        break;
                    default:
                        throw new MissingMemberException("Undefined factory for selected strategy!");
                }
                this.islands[i++]=new Island(factory,islandConfiguration,this);
            }
            Console.WriteLine("All islands initialized");
            //create connections
            this.connections = new IslandConnections(configuration.connections, this.islands);
            Console.WriteLine("Connections created");
            Console.WriteLine("Supervisor created");
        }