📄 paikecopy.cs
字号:
// if (k == cc) { t2 = CourseList[next[i] - 1].TeacherID; }
// if (t1 == t2)
// {
// Sum += ChongTu;
// }
// }
// }
// }
// return Sum;
// }
// int ComputeChongtuValue()
// {
// int Sum = 0;
// for (int i = 0; i < ClassUnit.WeekDay * ClassUnit.CourseCount; i++)
// {
// for (int j = 0; j < ClassList.Count; j++)
// {
// for (int k = j + 1; k < ClassList.Count; k++)
// {
// int t1 = CourseList[ClassList[j].XuLie[i] - 1].TeacherID;
// int t2 = CourseList[ClassList[k].XuLie[i] - 1].TeacherID;
// if (t1 == t2)
// {
// Sum += ChongTu;
// }
// }
// }
// }
// return Sum;
// }
// string PrntList()
// {
// string re = "";
// for (int i = 0; i < ClassList.Count; i++)
// {
// re += string.Format("班级{0}:\r\n", ClassList[i].Name);
// re += PrintDetail(ClassList[i]);
// }
// return re;
// }
// public void Test()
// {
// //primary configuration of cities
// Init();
// int[] next = new int[ClassUnit.WeekDay * ClassUnit.CourseCount];
// int iteration = -1;
// //the probability
// double proba;
// double alpha = 0.999;
// double temperature = 4000.0;
// double epsilon = 0.002;
// double delta;
// int i;
// double Value = 0;
// for (i = 0; i < ClassList.Count; i++)
// {
// Value += ComputeValue(ClassList[0].XuLie);
// }
// //Console.WriteLine("-----------当前最优值:{0}-------------", Value);
// //PrintDetail(ClassList[0]);
// //while the temperature didnt reach epsilon
// while (temperature > epsilon)
// {
// iteration++;
// //get the next random permutation of distances
// CreateNext(ClassList[0].XuLie, next);
// //compute the distance of the new permuted configuration
// delta = ComputeValue(next) - Value;
// //if the new distance is better accept it and assign it
// if (delta < 0)
// {
// assign(ClassList[0].XuLie, next);
// Value = delta + Value;
// //Console.WriteLine("-----------当前最优值:{0}-------------", Value);
// PrintDetail(ClassList[0]);
// ComputeValue(ClassList[0].XuLie);
// }
// else
// {
// proba = rnd.Next();
// //if the new distance is worse accept it but with a probability level
// // if the probability is less than E to the power -delta/temperature.
// //otherwise the old value is kept
// if (proba < Math.Exp(-delta / temperature))
// {
// assign(ClassList[0].XuLie, next);
// Value = delta + Value;
// }
// }
// //cooling proces on every iteration
// temperature *= alpha;
// //print every 400 iterations
// if (iteration % 400 == 0)
// {
// // Console.WriteLine(Value);
// }
// }
// }
// public void Test1()
// {
// //primary configuration of cities
// Init();
// List<string> ResolveList = new List<string>();
// int[] next = new int[ClassUnit.WeekDay * ClassUnit.CourseCount];
// int iteration = -1;
// //the probability
// double proba;
// double alpha = 0.9999;
// double temperature = 4000.0;
// double tcopy = temperature;
// double epsilon = 0.002;
// double delta;
// int i;
// int cc = 0;
// double Value = 0;
// for (i = 0; i < ClassList.Count; i++)
// {
// Value += ComputeValue(ClassList[0].XuLie);
// }
// Value += ComputeChongtuValue();
// //Console.WriteLine("-----------当前最优值:{0}-------------", Value);
// //PrintDetail(ClassList[0]);
// PrntList();
// Set set = new Set(AddText);
// SetNumber setnumber = new SetNumber(SetValue);
// int battc = 0;
// //while the temperature didnt reach epsilon
// while (temperature > epsilon)
// {
// battc++;
// if (battc > 100)
// {
// int tbarvalue = (int)(1000 - temperature / tcopy * 1000);
// TxtBox.Invoke(setnumber, new object[2] { tbarvalue, Bar });
// battc = 0;
// }
// iteration++;
// cc = cc % ClassList.Count;
// //get the next random permutation of distances
// CreateNext(ClassList[cc].XuLie, next);
// //compute the distance of the new permuted configuration
// delta = ComputeValue(next);
// for (i = 0; i < ClassList.Count; i++)
// {
// if (i == cc) { continue; }
// delta += ComputeValue(ClassList[i].XuLie); ;
// }
// delta += ComputeChongtuValue(next, cc);
// delta = delta - Value;
// if (delta <= 0 && ResolveList.Count <= 10)
// {
// string txt = string.Format("-----------代价:{0}-------------\r\n", Value);
// txt += PrntList();
// ResolveList.Add(txt);
// }
// //if the new distance is better accept it and assign it
// if (delta < 0)
// {
// ResolveList.Clear();
// assign(ClassList[cc].XuLie, next);
// Value = delta + Value;
// string txt = string.Format("-----------代价:{0}-------------\r\n", Value);
// txt += PrntList();
// ResolveList.Add(txt);
// //Console.WriteLine("-----------当前最优值:{0}-------------", Value);
// //PrntList();
// //ComputeValue(ClassList[0].XuLie);
// }
// else
// {
// proba = rnd.Next();
// //if the new distance is worse accept it but with a probability level
// // if the probability is less than E to the power -delta/temperature.
// //otherwise the old value is kept
// if (proba < Math.Exp(-delta / temperature))
// {
// assign(ClassList[cc].XuLie, next);
// Value = delta + Value;
// }
// }
// //cooling proces on every iteration
// temperature *= alpha;
// //print every 400 iterations
// if (iteration % 400 == 0)
// {
// // Console.WriteLine(Value);
// }
// cc++;
// }
// int ct = 0;
// foreach (string ss in ResolveList)
// {
// ct++;
// TxtBox.Invoke(set, new object[2] { string.Format("方案{0}\r\n", ct), TxtBox });
// TxtBox.Invoke(set, new object[2] { ss, TxtBox });
// }
// }
// }
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -