internal void ApplyValueHeuristic(ValueHeuristicType valueHeuristicType) { switch (valueHeuristicType) { case ValueHeuristicType.Random: { var r = new Random(); foreach (var v in variables) { v.domain.values = v.domain.values.OrderBy(x => r.Next()).ToList(); } break; } } }
public List <Solution <T> > Solve(VariableHeuristicType variableHeuristicType, ValueHeuristicType valueHeuristicType) { ResetValues(); stopwatch.Start(); Stopwatch stopwatchAll = new Stopwatch(); stopwatchAll.Start(); ApplyValueHeuristic(valueHeuristicType); ApplyVariableHeuristic(variableHeuristicType); switch (searchType) { case SearchType.ForwardChecking: { CloneDomains(); Solution <T> solution = new Solution <T>(invariables, variables); //Wykorzystując ograniczenia odfiltruj dziedziny zmiennych bez wartości solution.FilterOutDomains(); ForwardChecking(solution, 0); break; } case SearchType.Backtracking: { Solution <T> solution = new Solution <T>(invariables, variables); Backtracking(solution, 0); break; } } stopwatchAll.Stop(); Console.WriteLine("Total time: " + stopwatchAll.ElapsedMilliseconds); Console.WriteLine("Nodes visited till first solution: " + nodesFirst); Console.WriteLine("Nodes visited total: " + nodes); Console.WriteLine("Turn backs count till first solution: " + turnBacksFirst); Console.WriteLine("Turn backs count total: " + turnBacks); Console.WriteLine("Number of solutions: " + solutions.Count); return(solutions); }
public List <Solution <string> > Solve(VariableHeuristicType variableHeuristicType, ValueHeuristicType valueHeuristicType) { return(problem.Solve(variableHeuristicType, valueHeuristicType)); }