Package aima.core.search.framework

Examples of aima.core.search.framework.GraphSearch


*
*/
public class UniformCostSearch extends PrioritySearch {

  public UniformCostSearch() {
    this(new GraphSearch());
  }
View Full Code Here


    Problem rp = ((BidirectionalProblem) p).getReverseProblem();

    CachedStateQueue<Node> opFrontier = new CachedStateQueue<Node>();
    CachedStateQueue<Node> rpFrontier = new CachedStateQueue<Node>();

    GraphSearch ogs = new GraphSearch();
    GraphSearch rgs = new GraphSearch();
    // Ensure the instrumentation for these
    // are cleared down as their values
    // are used in calculating the overall
    // bidirectional metrics.
    ogs.clearInstrumentation();
    rgs.clearInstrumentation();

    Node opNode = new Node(op.getInitialState());
    Node rpNode = new Node(rp.getInitialState());
    opFrontier.insert(opNode);
    rpFrontier.insert(rpNode);

    setQueueSize(opFrontier.size() + rpFrontier.size());
    setNodesExpanded(ogs.getNodesExpanded() + rgs.getNodesExpanded());

    while (!(opFrontier.isEmpty() && rpFrontier.isEmpty())) {
      // Determine the nodes to work with and expand their fringes
      // in preparation for testing whether or not the two
      // searches meet or one or other is at the GOAL.
      if (!opFrontier.isEmpty()) {
        opNode = opFrontier.pop();
        opFrontier.addAll(ogs.getResultingNodesToAddToFrontier(opNode,
            op));
      } else {
        opNode = null;
      }
      if (!rpFrontier.isEmpty()) {
        rpNode = rpFrontier.pop();
        rpFrontier.addAll(rgs.getResultingNodesToAddToFrontier(rpNode,
            rp));
      } else {
        rpNode = null;
      }

      setQueueSize(opFrontier.size() + rpFrontier.size());
      setNodesExpanded(ogs.getNodesExpanded() + rgs.getNodesExpanded());

      //
      // First Check if either frontier contains the other's state
      if (null != opNode && null != rpNode) {
        Node popNode = null;
View Full Code Here

public class BreadthFirstSearch implements Search {

  private final QueueSearch search;

  public BreadthFirstSearch() {
    this(new GraphSearch());
  }
View Full Code Here

          .getPathCost())));
    }
  };

  public UniformCostSearch() {
    this(new GraphSearch());
  }
View Full Code Here

    switch (mode) {
    case TREE_SEARCH:
      qs = new TreeSearch();
      break;
    case GRAPH_SEARCH:
      qs = new GraphSearch();
    }
    switch (strategy) {
    case DF_SEARCH:
      result = new DepthFirstSearch(qs);
      break;
View Full Code Here

    try {
      Problem problem = new Problem(new NQueensBoard(8),
          NQueensFunctionFactory.getIActionsFunction(),
          NQueensFunctionFactory.getResultFunction(),
          new NQueensGoalTest());
      Search search = new DepthFirstSearch(new GraphSearch());
      SearchAgent agent = new SearchAgent(problem, search);
      printActions(agent.getActions());
      printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    try {
      Problem problem = new Problem(boardWithThreeMoveSolution,
          EightPuzzleFunctionFactory.getActionsFunction(),
          EightPuzzleFunctionFactory.getResultFunction(),
          new EightPuzzleGoalTest());
      Search search = new GreedyBestFirstSearch(new GraphSearch(),
          new MisplacedTilleHeuristicFunction());
      SearchAgent agent = new SearchAgent(problem, search);
      printActions(agent.getActions());
      printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
View Full Code Here

    try {
      Problem problem = new Problem(boardWithThreeMoveSolution,
          EightPuzzleFunctionFactory.getActionsFunction(),
          EightPuzzleFunctionFactory.getResultFunction(),
          new EightPuzzleGoalTest());
      Search search = new GreedyBestFirstSearch(new GraphSearch(),
          new ManhattanHeuristicFunction());
      SearchAgent agent = new SearchAgent(problem, search);
      printActions(agent.getActions());
      printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
View Full Code Here

        .println("\nEightPuzzleDemo AStar Search (MisplacedTileHeursitic)-->");
    try {
      Problem problem = new Problem(random1, EightPuzzleFunctionFactory
          .getActionsFunction(), EightPuzzleFunctionFactory
          .getResultFunction(), new EightPuzzleGoalTest());
      Search search = new AStarSearch(new GraphSearch(),
          new MisplacedTilleHeuristicFunction());
      SearchAgent agent = new SearchAgent(problem, search);
      printActions(agent.getActions());
      printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
View Full Code Here

        .println("\nEightPuzzleDemo AStar Search (ManhattanHeursitic)-->");
    try {
      Problem problem = new Problem(random1, EightPuzzleFunctionFactory
          .getActionsFunction(), EightPuzzleFunctionFactory
          .getResultFunction(), new EightPuzzleGoalTest());
      Search search = new AStarSearch(new GraphSearch(),
          new ManhattanHeuristicFunction());
      SearchAgent agent = new SearchAgent(problem, search);
      printActions(agent.getActions());
      printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of aima.core.search.framework.GraphSearch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.