0
private void CalculateFitness(TimeTable timeTable)
{
int score = 0, DAYS_NUM = 5;
score = timeTable.Exams.SelectMany(exam => exam.Students)
.GroupBy(s => s)
.Select(g => Connections(g.Count()))
.Sum();
timeTable.Fitness = score;
}
int Connections(int corners)
{
// 0+1+2+...+(corners-1)
return corners * (corners - 1)/2;
}
變量賦值是你的應用程序的瓶頸? – BrokenGlass 2011-01-12 14:49:26
如果不知道所涉及的類型,關係等等,很難提出改進建議。我相信有一個更好的方法,但是如果沒有更多細節,我們無法真正提供幫助。 – 2011-01-12 14:52:34