public Chromosom Run() { //NeuralNetwork nn = new NeuralNetwork(); //nn.InitialiseNetwork(listDataSet[0].AttributeCount, listDataSet[0].AttributeCount / 2, classificationClass.TargetCount); //nn.Seed = 0; //nn.InitialiseWeight(); //BackPropagation bp = new BackPropagation(); //bp.Initialise(nn, listDataSet, classificationClass); //bp.Run(); //FeedForward ff = new FeedForward(); //ff.Initialise(nn, listDataSet); //ff.Run(); ChromosomInit(); int iteration = 10; for (int i = 0; i < iteration; i++) { //Console.WriteLine("################## "+ i); DoBackPropagation(); DoSelection(); DoCrossOver(); int chanceMutation = GetRandom(); if (chanceMutation < GetRandom()) { DoMutation(); } } int index = 0; for (int i = 1; i < chromosoms.Count; i++) { if (chromosoms[i].FitnessValue > chromosoms[index].FitnessValue) { index = i; } } Chromosom fittestChromosom = chromosoms[index]; return(fittestChromosom); }
private void Btn_Read_Click(object sender, RoutedEventArgs e) { FileReader fr = new FileReader(); ListDataSet dsl = fr.ReadFile("DataSetBaru", cc); dsl.Normalized(); GeneticAlgorithm ga = new GeneticAlgorithm(); ga.Initialize(dsl, cc); fitChrom = ga.Run(); for (int i = 0; i < dsl.Count; i++) { int popCount = 0; for (int j = 0; j < fitChrom.Length; j++) { if (fitChrom[j] == 0) { dsl[i].RemoveBit(j - popCount); popCount++; } } } Stopwatch sw = Stopwatch.StartNew(); nn.InitialiseNetwork(dsl[0].AttributeCount, dsl[0].AttributeCount / 2, cc.TargetCount); nn.Seed = 0; nn.InitialiseWeight(); BackPropagation bp = new BackPropagation(); bp.Initialise(nn, dsl, cc); bp.Run(500); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds / 1000.0f); }