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


C# Cache.Sort方法代码示例

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


在下文中一共展示了Cache.Sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public void Run()
        {
            long percentComplete = 0;
            _exhuastiveCache = new Cache(10, 0.0);

            if ((_fitnessCrit == FitnessCriteria.R2) || (_fitnessCrit == FitnessCriteria.AdjustedR2))
            {
                _exhuastiveCache.Comparer = new DescendSort();
            }
            else if ((_fitnessCrit == FitnessCriteria.Sensitivity) || (_fitnessCrit == FitnessCriteria.Specificity) || (_fitnessCrit == FitnessCriteria.Accuracy))
            {
                _exhuastiveCache.Comparer = new DescendSort();
            }
            else
            {
                _exhuastiveCache.Comparer = new AscendSort();
            }

            IIndividual indiv = null;

            List<short> combList = new List<short>();
            short tmp = 0; ;
            for (int i = 0; i < _numVars; i++)
            {
                //ListItem li = (ListItem)lbIndVariables.Items[i];
                tmp = (short)(i + 1);
                //tmp += Convert.ToInt16(li.ValueItem);
                combList.Add(tmp);
            }

            long totalComb = 0;
            long totalComplete = 0;

            Combinations<short> combinations = null;
            List<Combinations<short>> listAllComb = new List<Combinations<short>>();
            for (short i = 1; i <= _maxVarsInModel; i++)
            {
                combinations = new Combinations<short>(combList.ToArray(), i, GenerateOption.WithoutRepetition);
                listAllComb.Add(combinations);
                totalComb += combinations.Count;
            }

            for (short i = 1; i <= _maxVarsInModel; i++)
            {
                if (Cancel)
                    break;

                //combinations = new Combinations<short>(combList.ToArray(), i, GenerateOption.WithoutRepetition);
                combinations = listAllComb[i - 1];
                foreach (IList<short> comb in combinations)
                {

                    if ((!Double.IsNaN(_decisionThreshold)) && (!Double.IsNaN(_mandateThreshold)) && (_maxVIF != Int32.MaxValue))
                        indiv = new MLRIndividual(i, i, _fitnessCrit, _maxVIF, _decisionThreshold, _mandateThreshold);
                    else if (_maxVIF != Int32.MaxValue)
                        indiv = new MLRIndividual(i, i, _fitnessCrit, _maxVIF);
                    else
                        indiv = new MLRIndividual(i, i, _fitnessCrit);

                    for (int j = 0; j < comb.Count; j++)
                        indiv.Chromosome[j] = comb[j];

                    if (Cancel)
                        break;

                    indiv.Evaluate();

                    if (indiv.IsViable())
                    {
                        //_exhuastiveCache.SortCache();
                        //_exhuastiveCache.ReplaceMinimum(indiv);
                        _exhuastiveCache.Add(indiv);
                    }
                    //else
                        //throw new Exception("Invalid individual.");

                    totalComplete++;

                    if ((totalComplete % 10) == 0)
                    {
                        percentComplete = totalComplete * 100 / totalComb;
                        ESProgress(percentComplete, _exhuastiveCache.MaximumFitness);
                        //VBLogger.getLogger().logEvent(percentComplete.ToString(), VBLogger.messageIntent.UserOnly, VBLogger.targetSStrip.ProgressBar);
                        //lblProgress.Text = "Progress: " + (Convert.ToDouble(totalComplete) / Convert.ToDouble(totalComb)) * 100;
                        //Console.WriteLine("Progress: " + (Convert.ToDouble(totalComplete) / Convert.ToDouble(totalComb)) * 100);
                        //lblProgress.Refresh();
                        //Application.DoEvents();
                    }

                }
            }
            _exhuastiveCache.Sort();

            //list = _exhuastiveCache.CacheList;

            //lbModels.Items.Clear();

            //UpdateFitnessListBox();
            ESComplete(this);
        }
开发者ID:wrbrooks,项目名称:VB3,代码行数:100,代码来源:ExhaustiveSearchManager.cs


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