private static List <List <double> > evaluateFitness(Plot plot, ApartmentGeneratorBase ag, Target target, List <ParameterSet> gene, double fitnessFactor, bool previewOn) { List <List <double> > result = new List <List <double> >(); List <double> grossAreaRatio = new List <double>(); List <double> parkinglotRatio = new List <double>(); List <double> targetAccuracy = new List <double>(); List <double> axisAccuracy = new List <double>(); bool drawSomeThing = false; int i = 0; var timer = new System.Threading.Timer((e) => { drawSomeThing = true; } , drawSomeThing, TimeSpan.Zero, TimeSpan.FromMilliseconds(1000)); List <Apartment> agOutToDrawList = new List <Apartment>(); List <double> agOutToDrawGrossAreaList = new List <double>(); for (i = 0; i < gene.Count(); i++) { Apartment tempOutput = ag.generator(plot, gene[i], target); grossAreaRatio.Add(tempOutput.GetGrossAreaRatio()); //targetAccuracy.Add(tempOutput.GetTargetAccuracy()); parkinglotRatio.Add(tempOutput.GetParkingScore()); axisAccuracy.Add(tempOutput.GetAxisAccuracy()); TuringAndCorbusierPlugIn.InstanceClass.page3.currentProgressFactor += 1; TuringAndCorbusierPlugIn.InstanceClass.page3.updateProGressBar(TuringAndCorbusierPlugIn.InstanceClass.page3.currentProgressFactor.ToString() + "/" + TuringAndCorbusierPlugIn.InstanceClass.page3.currentWorkQuantity.ToString() + " 진행중"); if (previewOn) { agOutToDrawList.Add(tempOutput); //agOutToDrawGrossAreaList.Add(tempOutput.GetGrossAreaRatio()); if (drawSomeThing) { TuringAndCorbusierPlugIn.InstanceClass.page3.preview(agOutToDrawList.Last()); Rhino.RhinoDoc.ActiveDoc.Views.Redraw(); Rhino.RhinoApp.Wait(); agOutToDrawList.Clear(); agOutToDrawGrossAreaList.Clear(); drawSomeThing = false; } } } double MaxFAR = TuringAndCorbusierPlugIn.InstanceClass.page1Settings.MaxFloorAreaRatio; //법정 용적률에 근접한 유전자가 가장 높은 값 받음, // -0 ~ -5 최대값 받음 //넘어가면 * 0.01 포인트 마이너스 //낮으면 *0.1포인트 마이너스 List <double> points = new List <double>(); for (int r = 0; r < grossAreaRatio.Count; r++) { double point = 0; if (grossAreaRatio[r] < MaxFAR && grossAreaRatio[r] > MaxFAR - 5) { point = 1 + (5 - (MaxFAR - grossAreaRatio[r])) / MaxFAR; } else if (grossAreaRatio[r] > MaxFAR) { point = 1 - (grossAreaRatio[r] - MaxFAR) / MaxFAR / 10; } else { point = 1 - (MaxFAR - grossAreaRatio[r]) / MaxFAR; } points.Add(point); } List <double> tempGAR = new List <double>(grossAreaRatio); RhinoList <double> FARList = new RhinoList <double>(tempGAR); //FARList.Sort(points.ToArray()); //points.Sort(); double Cworst = FARList.First; double Cbest = FARList.Last; double k = fitnessFactor; List <double> fitness = new List <double>(); //double Cworst = tempGAR[0]; //double Cbest = tempGAR[gene.Count - 1]; //double k = fitnessFactor; //List<double> fitness = new List<double>(); double parkingWeight = 0.3; double CworstR = parkinglotRatio.Min(); double CbestR = parkinglotRatio.Max(); double targetWeight = 0.4; //double CworstT = targetAccuracy.Min(); //double CbestT = targetAccuracy.Max(); //fitnessvalue rate //연면적 1 : 주차율(?) 0.3 : 유닛정확도 : 0.4 //for test //string url = @"C://Users//user//Desktop//test"; //System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(url); //string filename = "//garojutacklogV2" + (dinfo.GetFiles().Length + 1).ToString() + ".csv"; //System.IO.FileStream fs = new System.IO.FileStream(url + filename, System.IO.FileMode.CreateNew); //fs.Close(); //fs.Dispose(); //System.IO.StreamWriter w = new System.IO.StreamWriter(fs.Name); //string column = "FAR" + "," + "Floors" + "," + "FARPoint" + "," + "ParkingPoint" + "," + "AxisPoint" + "," + "Sum" + "," + "Use1F" + ",UseSetback"; //w.WriteLine(column); for (int j = 0; j < gene.Count; j++) { double farfitnessVal = points[j] * 10; double parkkingfitnessVal = parkinglotRatio[j]; double axisfitnessVal = axisAccuracy[j]; //double farfitnessVal = ((grossAreaRatio[j] - Cbest) * (k - 1) / k + (Cbest - Cworst) + 0.01) / (Cbest - Cworst + 0.01); //double parkingval = ((parkinglotRatio[j] - CbestR) * (k - 1) / k + (CbestR - CworstR) + 0.01) / (CbestR - CworstR + 0.01) * parkingWeight; //double targetval = ((targetAccuracy[j] - CbestT) * (k - 1) / k + (CbestT - CworstT) + 0.01) / (CbestT - CworstT + 0.01) * targetWeight; //firstfloor test double firstfloorBonus = 0; //if (gene[j].using1F) // firstfloorBonus = 1000; //setback test double setbackBonus = 0; //if (gene[j].setback) // setbackBonus = 1000; fitness.Add(farfitnessVal + parkkingfitnessVal + axisfitnessVal + setbackBonus + firstfloorBonus); //for test //string format = grossAreaRatio[j].ToString() + "," + gene[j].Stories + "," + farfitnessVal + "," + parkkingfitnessVal + "," + axisfitnessVal + "," + (farfitnessVal + parkkingfitnessVal + axisfitnessVal).ToString() + "," + gene[j].using1F.ToString() + "," + gene[j].setback.ToString(); //w.WriteLine(format); } //for test //w.Close(); //w.Dispose(); //tempGAR.Reverse(); //fitness.Reverse(); //FARList.Reverse(); result.Add(fitness); result.Add(FARList.Select(n => n).ToList()); double maxfar = FARList.Max(); double maxfitness = fitness.Max(); TuringAndCorbusierPlugIn.InstanceClass.page3.updateProGressBar(TuringAndCorbusierPlugIn.InstanceClass.page3.currentProgressFactor.ToString() + "/" + TuringAndCorbusierPlugIn.InstanceClass.page3.currentWorkQuantity.ToString() + " 완료"); return(result); //or, return nested list, containing gross area ratio. }