本文整理汇总了C#中Population.NextGeneration方法的典型用法代码示例。如果您正苦于以下问题:C# Population.NextGeneration方法的具体用法?C# Population.NextGeneration怎么用?C# Population.NextGeneration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population.NextGeneration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlan
public string GetPlan(string pStrPriority)
{
string lvRes = "";
string lvStrTrainAllowed = "";
int lvPopulationSize = 0;
int lvMaxGenerations = 0;
int lvMutationRate = 0;
IFitness<Gene> lvFitness = null;
Population lvPopulation = null;
TrainIndividual lvTrainIndividual = null;
bool lvLogEnable = DebugLog.mEnable;
if (!DateTime.TryParse(ConfigurationManager.AppSettings["INITIAL_DATE"], out mInitialDate))
{
mInitialDate = DateTime.Now.Date;
mFinalDate = mInitialDate.Date == DateTime.Now.Date ? DateTime.Now : mInitialDate.Date.AddDays(1).AddSeconds(-1);
}
else
{
mFinalDate = mInitialDate.Date + DateTime.Now.TimeOfDay;
}
TrainIndividual.VMA = double.Parse(ConfigurationManager.AppSettings["VMA"]);
TrainIndividual.TrainLen = int.Parse(ConfigurationManager.AppSettings["TRAIN_LEN"]);
TrainIndividual.LimitDays = int.Parse(ConfigurationManager.AppSettings["LIMIT_DAYTIME"]);
DebugLog.mEnable = true;
DebugLog.Logar("TrainIndividual.VMA = " + TrainIndividual.VMA);
DebugLog.Logar("TrainIndividual.TrainLen = " + TrainIndividual.TrainLen);
lvPopulationSize = int.Parse(ConfigurationManager.AppSettings["POPULATION_SIZE"]);
lvMaxGenerations = int.Parse(ConfigurationManager.AppSettings["MAX_GENERATIONS"]);
lvMutationRate = int.Parse(ConfigurationManager.AppSettings["MUTATION_RATE"]);
lvStrTrainAllowed = ConfigurationManager.AppSettings["TRAIN_TYPE_ALLOWED"];
Population.TrainAllowed = lvStrTrainAllowed;
DebugLog.Logar("lvPopulationSize = " + lvPopulationSize);
DebugLog.Logar("lvMaxGenerations = " + lvMaxGenerations);
DebugLog.Logar("lvMutationRate = " + lvMutationRate);
DebugLog.Logar("lvStrTrainAllowed = " + lvStrTrainAllowed);
DebugLog.Logar("lvInitialDate = " + mInitialDate);
DebugLog.Logar("lvFinalDate = " + mFinalDate);
StopLocation.LoadList();
Segment.LoadList();
// Interdicao.LoadList(mInitialDate, mFinalDate);
Interdicao.LoadList(DateTime.Now, DateTime.Now);
TrainIndividual.LoadPATs(mInitialDate, mFinalDate);
TrainPerformanceControl.LoadDic();
DebugLog.Logar(" ");
DebugLog.mEnable = lvLogEnable;
lvFitness = new RailRoadFitness();
lvPopulation = new Population(lvFitness, lvPopulationSize, lvMutationRate, true, mInitialDate, mFinalDate, pStrPriority);
DebugLog.mEnable = true;
DebugLog.Logar(" ");
DebugLog.Logar("Individuos = " + lvPopulation.Count);
DebugLog.Logar(" ");
DebugLog.mEnable = lvLogEnable;
for (int i = 0; i < lvMaxGenerations; i++)
{
DebugLog.mEnable = true;
DebugLog.Logar("Generation = " + i);
DebugLog.mEnable = lvLogEnable;
lvPopulation.NextGeneration();
lvPopulation.dump();
}
lvTrainIndividual = (TrainIndividual)lvPopulation.GetIndividualAt(0);
DebugLog.mEnable = true;
DebugLog.Logar("Melhor = " + lvTrainIndividual.ToString());
lvRes = lvTrainIndividual.GetFlotSeries();
DebugLog.Logar("lvRes = " + lvRes);
DebugLog.mEnable = lvLogEnable;
return lvRes;
}