public EvolutionaryStrategies(string configFilename) { // Grab the config info _configFilename = configFilename; var config = Toml.ReadFile <Configuration>(_configFilename); _params = config.Search; // Setup the deck pool and grab our deck and class var deckPoolManager = new DeckPoolManager(); deckPoolManager.AddDeckPools(config.Evaluation.DeckPools); string poolName = config.Player.DeckPool; string deckName = config.Player.DeckName; Console.WriteLine(string.Format("names {0} {1}", poolName, deckName)); _playerDeck = deckPoolManager.GetDeck(poolName, deckName); // Setup the logs to record the data on individuals InitLogs(); }
public DistributedSearch(string configFilename) { // Grab the config info _configFilename = configFilename; var config = Toml.ReadFile <Configuration>(_configFilename); // Figure out the number of search parameters based on whether // we are searching a linear combination or neural network weights int numParams = -1; if (config.Evaluation.PlayerStrategies[0].Strategy == "Custom") { numParams = 15; } else if (config.Evaluation.PlayerStrategies[0].Strategy == "NeuralNet") { // Peak in to the neural network configuration and compute // the number of parameters we need to compute weights for. int[] layerSizes = config.Network.LayerSizes; numParams = 0; for (int i = 0; i < layerSizes.Length - 1; i++) { numParams += layerSizes[i] * layerSizes[i + 1]; // edge weights numParams += layerSizes[i + 1]; // bias weights } } Console.WriteLine(string.Format("Search for {0} parameters...", numParams)); // Setup the search algorithm to use to optimize the strategy. if (config.Search.Type.Equals("EvolutionStrategy")) { var searchConfig = Toml.ReadFile <EvolutionStrategyParams>(config.Search.ConfigFilename); _searchAlgo = new EvolutionStrategyAlgorithm(searchConfig, numParams); } else if (config.Search.Type.Equals("CMA-ES")) { var searchConfig = Toml.ReadFile <CMA_ES_Params>(config.Search.ConfigFilename); _searchAlgo = new CMA_ES_Algorithm(searchConfig, numParams); } else if (config.Search.Type.Equals("CMA-ME")) { var searchConfig = Toml.ReadFile <CMA_ME_Params>(config.Search.ConfigFilename); _searchAlgo = new CMA_ME_Algorithm(searchConfig, numParams); } else if (config.Search.Type.Equals("MAP-Elites")) { var searchConfig = Toml.ReadFile <MapElitesParams>(config.Search.ConfigFilename); _searchAlgo = new MapElitesAlgorithm(searchConfig, numParams); } else if (config.Search.Type.Equals("MAP-Elites-Line")) { var searchConfig = Toml.ReadFile <MapElitesParams>(config.Search.ConfigFilename); _searchAlgo = new MapElitesLineAlgorithm(searchConfig, numParams); } else { Console.WriteLine(string.Format("Strategy {} not supported.", config.Search.Type)); } // Setup the deck pool and grab our deck and class var deckPoolManager = new DeckPoolManager(); deckPoolManager.AddDeckPools(config.Evaluation.DeckPools); string poolName = config.Player.DeckPool; string deckName = config.Player.DeckName; Console.WriteLine(string.Format("names {0} {1}", poolName, deckName)); _playerDeck = deckPoolManager.GetDeck(poolName, deckName); // Setup the logs to record the data on individuals InitLogs(); }