private void fillStrings() { GADataSet ds = GARow.Table.DataSet as GADataSet; for (int i = 0; i < listOfSolutions.Count; i++) { GADataSet.SolutionsRow currentSolution = listOfSolutions.ElementAt(i); GADataSet.StringsRow currentString; currentString = ds.Strings.NewStringsRow(); currentString.Initialize(); ds.Strings.AddStringsRow(currentString); currentString.GAID = currentSolution.GAID; currentString.ProblemID = currentSolution.ProblemID; currentString.SolutionID = currentSolution.ID; currentSolution.Counter = 1; //decode FillStrings(ref currentSolution, ref currentString); // GNUPLOT(ref currentSolution); //assign string ID... //this should be better } }
/// <summary> /// Main postcript function to store best results /// </summary> private void workerProgressChanged(object sender, ProgressChangedEventArgs e) { try { IChromosome bestChromosome = GA.Population.BestChromosome; //BASIC GADataSet ds = GARow.Table.DataSet as GADataSet; GADataSet.SolutionsRow currentSolution; currentSolution = ds.Solutions.NewSolutionsRow(); currentSolution.Initialize(bestChromosome.GetGenes()); currentSolution.ProblemID = PROBLEMID; //this is the most important function to override, does the fitness calc FillBasic(ref currentSolution); GeneticAlgorithm ga = GA; //fill GA data to row GARow.Update(ref ga); //report GA stuff //define filter function by genotype Func <GADataSet.SolutionsRow, bool> funcion; funcion = Aid.FilterByGenotype(ref hashListOfGenotypes, ref listOfSolutions); //execute filter function by genotype funcion(currentSolution); //the listOfSolutions contains the list of rows that need to be added //these rows are flagged ShouldDelete = false //REPONER ESTO if (!currentSolution.ShouldDelete) { ds.Solutions.AddSolutionsRow(currentSolution); GARow.FillGADataToSolution(ref currentSolution); } //callBack MEthod to Form or User Control CallBack.Invoke(); } catch (Exception ex) { throw ex; } }