当前位置: 首页>>代码示例>>C#>>正文


C# Population.GetIndividualAt方法代码示例

本文整理汇总了C#中Population.GetIndividualAt方法的典型用法代码示例。如果您正苦于以下问题:C# Population.GetIndividualAt方法的具体用法?C# Population.GetIndividualAt怎么用?C# Population.GetIndividualAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Population的用法示例。


在下文中一共展示了Population.GetIndividualAt方法的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;
    }
开发者ID:eggopinheiro,项目名称:weboptimization,代码行数:87,代码来源:GAOptimization.cs


注:本文中的Population.GetIndividualAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。