Package aima.core.search.framework

Examples of aima.core.search.framework.Search


  public void testBreadthFirstUnSuccesfulSearch() throws Exception {
    Problem problem = new Problem(new NQueensBoard(3),
        NQueensFunctionFactory.getIActionsFunction(),
        NQueensFunctionFactory.getResultFunction(),
        new NQueensGoalTest());
    Search search = new BreadthFirstSearch(new TreeSearch());
    SearchAgent agent = new SearchAgent(problem, search);
    List<Action> actions = agent.getActions();
    Assert.assertEquals(0, actions.size());
    Assert.assertEquals("6",
        agent.getInstrumentation().getProperty("nodesExpanded"));
View Full Code Here


  public void testDepthFirstSuccesfulSearch() throws Exception {
    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);
    List<Action> actions = agent.getActions();
    assertCorrectPlacement(actions);
    Assert.assertEquals("113",
        agent.getInstrumentation().getProperty("nodesExpanded"));
View Full Code Here

  public void testDepthFirstUnSuccessfulSearch() throws Exception {
    Problem problem = new Problem(new NQueensBoard(3),
        NQueensFunctionFactory.getIActionsFunction(),
        NQueensFunctionFactory.getResultFunction(),
        new NQueensGoalTest());
    Search search = new DepthFirstSearch(new GraphSearch());
    SearchAgent agent = new SearchAgent(problem, search);
    List<Action> actions = agent.getActions();
    Assert.assertEquals(0, actions.size());
    Assert.assertEquals("6",
        agent.getInstrumentation().getProperty("nodesExpanded"));
View Full Code Here

    try {
      Problem problem = new Problem(new NQueensBoard(8),
          NQueensFunctionFactory.getIActionsFunction(),
          NQueensFunctionFactory.getResultFunction(),
          new NQueensGoalTest());
      Search search = new IterativeDeepeningSearch();
      SearchAgent agent = new SearchAgent(problem, search);
      List<Action> actions = agent.getActions();
      assertCorrectPlacement(actions);
      Assert.assertEquals("3656",
          agent.getInstrumentation().getProperty("nodesExpanded"));
View Full Code Here

  public void testSuccesfulDepthLimitedSearch() throws Exception {
    Problem problem = new Problem(new NQueensBoard(8),
        NQueensFunctionFactory.getIActionsFunction(),
        NQueensFunctionFactory.getResultFunction(),
        new NQueensGoalTest());
    Search search = new DepthLimitedSearch(8);
    SearchAgent agent = new SearchAgent(problem, search);
    List<Action> actions = agent.getActions();
    assertCorrectPlacement(actions);
    Assert.assertEquals("113",
        agent.getInstrumentation().getProperty("nodesExpanded"));
View Full Code Here

      Problem problem = new Problem(board,
          EightPuzzleFunctionFactory.getActionsFunction(),
          EightPuzzleFunctionFactory.getResultFunction(),
          new EightPuzzleGoalTest());
      Search search = new AStarSearch(new GraphSearch(),
          new ManhattanHeuristicFunction());
      SearchAgent agent = new SearchAgent(problem, search);
      Assert.assertEquals(23, agent.getActions().size());
      Assert.assertEquals("926",
          agent.getInstrumentation().getProperty("nodesExpanded"));
View Full Code Here

        MapFunctionFactory.getActionsFunction(romaniaMap),
        MapFunctionFactory.getResultFunction(), new DefaultGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST),
        new MapStepCostFunction(romaniaMap));

    Search search = new AStarSearch(new GraphSearch(),
        new StraightLineDistanceHeuristicFunction(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST, romaniaMap));
    SearchAgent agent = new SearchAgent(problem, search);

    List<Action> actions = agent.getActions();

    Assert.assertEquals(
        "[Action[name==moveTo, location==RimnicuVilcea], Action[name==moveTo, location==Pitesti], Action[name==moveTo, location==Bucharest]]",
        actions.toString());
    Assert.assertEquals("278.0",
        search.getMetrics().get(QueueSearch.METRIC_PATH_COST));
  }
View Full Code Here

        MapFunctionFactory.getActionsFunction(romaniaMap),
        MapFunctionFactory.getResultFunction(), new DefaultGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST),
        new MapStepCostFunction(romaniaMap));

    Search search = new AStarSearch(new TreeSearch(),
        new StraightLineDistanceHeuristicFunction(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST, romaniaMap));
    SearchAgent agent = new SearchAgent(problem, search);
    Assert.assertEquals(
        "[Action[name==moveTo, location==Sibiu], Action[name==moveTo, location==RimnicuVilcea], Action[name==moveTo, location==Pitesti], Action[name==moveTo, location==Bucharest]]",
View Full Code Here

        MapFunctionFactory.getActionsFunction(romaniaMap),
        MapFunctionFactory.getResultFunction(), new DefaultGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST),
        new MapStepCostFunction(romaniaMap));

    Search search = new AStarSearch(new GraphSearch(),
        new StraightLineDistanceHeuristicFunction(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST, romaniaMap));
    SearchAgent agent = new SearchAgent(problem, search);
    Assert.assertEquals(
        "[Action[name==moveTo, location==Sibiu], Action[name==moveTo, location==RimnicuVilcea], Action[name==moveTo, location==Pitesti], Action[name==moveTo, location==Bucharest]]",
View Full Code Here

    HeuristicFunction hf = new HeuristicFunction() {
      public double h(Object state) {
        return 0; // Don't have one for this test
      }
    };
    Search search = new AStarSearch(new GraphSearch(), hf);
    SearchAgent agent = new SearchAgent(problem, search);

    List<Action> actions = agent.getActions();

    Assert.assertEquals(
        "[Action[name==moveTo, location==b], Action[name==moveTo, location==d], Action[name==moveTo, location==goal]]",
        actions.toString());
    Assert.assertEquals("5.5",
        search.getMetrics().get(QueueSearch.METRIC_PATH_COST));
  }
View Full Code Here

TOP

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

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.