public Candidate(int generation, List <int> genotype, GeneticSolver solver, string time) { this.time = time; this.generation = generation; this.solver = solver; chromoson = genotype; CountFitness(); }
public static void createNewSolver(int mutationIndex, int crossoverIndex, int selectorIndex, int populationSize, float mutationChance, int timeMS, int selectorSize, float crossoverChance) { MutationType mutation = null; CrossoverType crossover = null; SelectionType selection = null; AdjacencyMatrix matrix = new AdjacencyMatrix(tspXmlFile); switch (mutationIndex) { case 0: { mutation = new InversionMutation(mutationChance); break; } case 1: { mutation = new TranspositionMutation(mutationChance); break; } } switch (crossoverIndex) { case 0: { crossover = new PMXCrossover(crossoverChance); break; } case 1: { crossover = new OXCrossover(crossoverChance); break; } } switch (selectorIndex) { case 0: { selection = new TournamentSelection(selectorSize); break; } case 1: { selection = new RouletteSelection(selectorSize); break; } } GeneticSolver solver = null;//add parameters TO DO if (mutation != null && selection != null && crossover != null) { addNewSolver(new GeneticSolver(matrix, mutation, crossover, selection, populationSize, timeMS)); } }
public static void addNewSolver(GeneticSolver solver) { if (solver != null) { listTask.Add(solver); } else { Console.WriteLine("Error. Wrong solver parameters"); } }
public Result(GeneticSolver solver) { mutationName = solver.mutation.MutationName; selectionName = solver.selector.SelectionName; crossoverName = solver.crossover.CrossoverName; mutationChance = solver.mutation.mutationChance; tspFileName = solver.matrix.tspFileName; overCrossChance = solver.crossover.CrossoverChance; time = solver.time.ElapsedMilliseconds.ToString(); populationSize = solver.maxPopulationSize; selectionSize = solver.selector.selectionSize; measureName = tspFileName + "Size" + populationSize + mutationName + mutationChance + selectionName + selectionSize + crossoverName + overCrossChance + "TIME" + solver.MaxTime + "s"; bestResult = solver.bestCandidate; results = solver.results; TimeResults = solver.bestPerTwoMinutes; }