public void setUp() { envChanges = TextFactory.CreateStringBuilder(); BidirectionalSearch <string, MoveToAction> bidirectionalSearch = new BidirectionalSearch <string, MoveToAction>(); search = new BreadthFirstSearch <string, MoveToAction>(bidirectionalSearch); }
public async Task <IEnumerable <ActorNode> > GetConnectionsAsync(string actorA, string actorB) { var lookupResults = new Task <ActorNode>[] { LookupActor(actorA), LookupActor(actorB) }; var actors = await Task.WhenAll(lookupResults); var bidiSearch = new BidirectionalSearch <ActorNode>( GetFirstDegreeConnections, GetFirstDegreeConnections, RepairPath); var path = bidiSearch.FindPath(actors[0], actors[1]); return(path); }
public aima.core.search.framework.Search GetSearch(Object owner, IContextLookup globalVars, HeuristicFunction objHeuristicFunction) { aima.core.search.framework.Search toReturn; QueueSearch objQueueSearch; switch (QueueSearchType) { case QueueSearchType.TreeSearch: objQueueSearch = new TreeSearch(); break; default: objQueueSearch = new GraphSearch(); break; } switch (AlgorithmType) { case SearchAlgorithmType.KnownInformed: switch (KnownInformedAlgorithm) { case KnownInformedSearch.GreedyBestFirst: toReturn = new GreedyBestFirstSearch(objQueueSearch, objHeuristicFunction); break; case KnownInformedSearch.RecursiveGreedyBestFirst: toReturn = new RecursiveBestFirstSearch(new GreedyBestFirstEvaluationFunction(objHeuristicFunction)); break; case KnownInformedSearch.RecursiveAStar: toReturn = new RecursiveBestFirstSearch(new AStarEvaluationFunction(objHeuristicFunction)); break; case KnownInformedSearch.HillClimbing: toReturn = new HillClimbingSearch(objHeuristicFunction); break; case KnownInformedSearch.SimulatedAnnealing: toReturn = new SimulatedAnnealingSearch(objHeuristicFunction); break; default: toReturn = new AStarSearch(objQueueSearch, objHeuristicFunction); break; } break; case SearchAlgorithmType.KnownUninformed: switch (KnownUninformedAlgorithm) { case KnownUninformedSearch.DepthFirst: toReturn = new DepthFirstSearch(objQueueSearch); break; case KnownUninformedSearch.DepthLimited: toReturn = new DepthLimitedSearch(DepthLimit); break; case KnownUninformedSearch.IterativeDeepening: toReturn = new IterativeDeepeningSearch(); break; case KnownUninformedSearch.UniformCost: toReturn = new UniformCostSearch(objQueueSearch); break; case KnownUninformedSearch.Bidirectional: toReturn = new BidirectionalSearch(); break; default: toReturn = new BreadthFirstSearch(objQueueSearch); break; } break; default: toReturn = CustomSearchAlgorithm.EvaluateTyped(owner, globalVars); break; } return(toReturn); }
public static void UninformedAlgorithms() { Console.WriteLine("Welcome\nARTIFICIAL INTELLIGENCE SEARCH ALGORITHMS"); ShowOptions(); var input = Console.ReadLine(); int res = 1; while (int.TryParse(input, out res) == false) { ShowOptions(); input = Console.ReadLine(); } Node <string> startNode = null; Node <string> goalNode = null; switch (Convert.ToInt32(input)) { case 1: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("BREADTH FIRST SEARCH IMPLEMENTATION------------"); var bfs = new BreadthFirstSearch <string>(goalNode, startNode); bfs.Search(); } break; case 2: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("DEPTH FIRST SEARCH IMPLEMENTATION------------"); var dfs = new DepthFirstSearch <string>(goalNode, startNode); dfs.Search(); } break; case 3: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("\nEnd\n"); Console.WriteLine("ITERATIVE DEEPENING SEARCH IMPLEMENTATION------------"); var ids = new IterativeDeepingSearch <string>(goalNode, startNode); ids.Search(); } break; case 4: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("DEPTH LIMITED SEARCH IMPLEMENTATION------------"); Console.Write("Enter limit to search: "); var limit = int.Parse(Console.ReadLine()); var dls = new DepthLimitedSearch <string>(goalNode, startNode, limit); dls.Search(); } break; case 5: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("Enter the cost for the nodes"); foreach (var node in Nodes) { Console.Write($"Enter cost for node: {node.NodeName}: "); node.Cost = double.Parse(Console.ReadLine()); } Console.WriteLine("UNIFORM COST SEARCH IMPLEMENTATION------------"); var ucs = new UniformCostSearch <string>(goalNode, startNode); ucs.Search(); } break; case 6: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("BIDIRECTIONAL SEARCH IMPLEMENTATION------------"); var bidi = new BidirectionalSearch <string>(goalNode, startNode); bidi.Search(); } break; default: ShowOptions(); break; } }
public void Setup() { g = new Graph("graph_matrix.txt", "heuristic_data.txt"); br = new Model.BidirectionalSearch(); gs = new GreedySearch(); }
/** * Creates a search instance. * * @param strategy * search strategy. See static constants. * @param qSearchImpl * queue search implementation: e.g. {@link #TREE_SEARCH}, {@link #GRAPH_SEARCH} * */ public ISearchForActions <S, A> createSearch <S, A>(int strategy, int qSearchImpl, IToDoubleFunction <Node <S, A> > h) { QueueSearch <S, A> qs = null; ISearchForActions <S, A> result = null; switch (qSearchImpl) { case TREE_SEARCH: qs = new TreeSearch <S, A>(); break; case GRAPH_SEARCH: qs = new GraphSearch <S, A>(); break; case GRAPH_SEARCH_RED_FRONTIER: qs = new GraphSearchReducedFrontier <S, A>(); break; case GRAPH_SEARCH_BFS: qs = new GraphSearchBFS <S, A>(); break; case BIDIRECTIONAL_SEARCH: qs = new BidirectionalSearch <S, A>(); break; } switch (strategy) { case DF_SEARCH: result = new DepthFirstSearch <S, A>(qs); break; case BF_SEARCH: result = new BreadthFirstSearch <S, A>(qs); break; case ID_SEARCH: result = new IterativeDeepeningSearch <S, A>(); break; case UC_SEARCH: result = new UniformCostSearch <S, A>(qs); break; case GBF_SEARCH: result = new GreedyBestFirstSearch <S, A>(qs, h); break; case ASTAR_SEARCH: result = new AStarSearch <S, A>(qs, h); break; case RBF_SEARCH: result = new RecursiveBestFirstSearch <S, A>(new AStarSearch <S, A> .EvalFunction(h)); break; case RBF_AL_SEARCH: result = new RecursiveBestFirstSearch <S, A>(new AStarSearch <S, A> .EvalFunction(h), true); break; case HILL_SEARCH: result = new HillClimbingSearch <S, A>(h); break; } return(result); }