//Set IBEA parameters and start IBEA private void StartIBEA(object sender, RoutedEventArgs e) { DateTime beginTime = DateTime.Now; array_ParetoFront = ibeaEng.GetParetoFront(); ShowParetoFront(); DateTime finishTime = DateTime.Now; //计算所有解的重复数量 int differentSolutions = 0; for (int i = 0; i < array_ParetoFront.Count - 1; i++) { int sameCount = 0; for (int j = i + 1; j < array_ParetoFront.Count; j++) { ParetoPoint p1 = (ParetoPoint)array_ParetoFront[i]; ParetoPoint p2 = (ParetoPoint)array_ParetoFront[j]; if (p1.X == p2.X) { sameCount++; } } if (sameCount == 0) { differentSolutions++; } } MessageBox.Show("共找到Pareto前沿上的点" + array_ParetoFront.Count.ToString() + "个\n排除重复后有" + differentSolutions + "个不同的解\n共耗时" + (finishTime - beginTime).TotalSeconds + "秒"); }
// Get population p public ArrayList GetP() { ArrayList a = new ArrayList(); for (int i = 0; i < popP.size; i++) { Double x = Decode(popP.aGenome[i]); ParetoPoint paretoPoint = new ParetoPoint(x, optFunc1(popP.aGenome[i]), optFunc2(popP.aGenome[i])); a.Add(paretoPoint); } return(a); }
public ArrayList GetQ() { ArrayList a = new ArrayList(); for (int i = 0; i < popQ.size; i++) { if (IsLegal(popQ.aGenome[i]) == true) { Double x = Decode(popQ.aGenome[i]); ParetoPoint paretoPoint = new ParetoPoint(x, optFunc1(popQ.aGenome[i]), optFunc2(popQ.aGenome[i])); a.Add(paretoPoint); } } Console.WriteLine("Generation {0}:{1}", generation, a.Count); return(a); }
// Get the arraylist of Pareto-Front public ArrayList GetParetoFront() { if (aParetoFront == null) { return(null); } else { ArrayList a = new ArrayList(); foreach (Genome genome in aParetoFront) { Double x = Decode(genome); ParetoPoint paretoPoint = new ParetoPoint(x, optFunc1(genome), optFunc2(genome)); a.Add(paretoPoint); } return(a); } }