public void BestFirst_Sample2SumDistanceAway_GeneratesSolution() { ISearchAlgorithm searchAlgorithm = new BestFirst(); var state = new List<int>(new int[] { 1, 2, 3, 4, 12, 13, 14, 5, 11, Node.SPACE, 15, 6, 10, 9, 8, 7 }); var initialNode = new Node { State = state }; searchAlgorithm.Heuristic = HeuristicFunctions.sum_distance_of_tiles_away_from_their_place; var solutionPath = searchAlgorithm.Search(initialNode); Assert.IsTrue(HelperMethods.SolutionPathLeadsToGoal(solutionPath)); HelperMethods.OutputResults(solutionPath, searchAlgorithm, state); }
public void BestFirst_Sample1NumTilesOutOfOrder_GeneratesSolution() { ISearchAlgorithm searchAlgorithm = new BestFirst(); var state = new List<int>(new int[] {1, 2, Node.SPACE, 3, 6, 7, 11, 4, 5, 9, 12, 8, 13, 10, 14, 15}); var initialNode = new Node {State = state}; searchAlgorithm.Heuristic = HeuristicFunctions.number_of_tiles_out_of_place; var solutionPath = searchAlgorithm.Search(initialNode); Assert.AreEqual(13, solutionPath.Count); Assert.IsTrue(HelperMethods.SolutionPathLeadsToGoal (solutionPath)); HelperMethods.OutputResults(solutionPath, searchAlgorithm, state); }
static void Main(string[] args) { Problema p = new Problema(); Heurisztika h = new Heurisztika(); BestFirst bestFirst = new BestFirst(); List <Operator> megoldas = bestFirst.keres(p, h); megoldas.ForEach(Console.WriteLine); Console.WriteLine("Befejezéshez nyomj meg egy gombot!"); Console.ReadKey(); }
public void simple_attribute_selection_tests_with_indexes() { Runtime rt = Runtime.LoadFromFile <TitanicDataRow>(0, TestingHelpers.GetResourceFileName("titanic_train.csv")); BestFirst alg = rt.AttributeSelections.Algorithms.BestFirst. Direction(BestFirst.EDirection.Bi_directional). LookupCacheSize(10); PicNetML.AttrSel.Evals.CfsSubset eval = rt.AttributeSelections.Evaluators.CfsSubset. LocallyPredictive(true). MissingSeparate(true); int[] indexes = alg.SearchIndexes(eval); Assert.AreEqual(new[] { 2, 0 }, indexes); }
static void StartBestFirst(int initstate) { try { BestFirst o = new BestFirst(initstate); Console.Write("\rBest First Search starts . . . Please wait"); o.Solve(); } catch (Exception e) { HandleException(e); } }
public void simple_attribute_selection_tests_with_new_runtime() { Runtime rt = Runtime.LoadFromFile <TitanicDataRow>(0, TestingHelpers.GetResourceFileName("titanic_train.csv")); BestFirst alg = rt.AttributeSelections.Algorithms.BestFirst. Direction(BestFirst.EDirection.Bi_directional). LookupCacheSize(10); PicNetML.AttrSel.Evals.CfsSubset eval = rt.AttributeSelections.Evaluators.CfsSubset. LocallyPredictive(true). MissingSeparate(true); Runtime newrt = alg.Search(eval); string[] names = newrt.EnumerateAttributes.Select(a => a.Name).ToArray(); Assert.AreEqual(new[] { "sex", "survived" }, names); }