本文整理汇总了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);
}