Package aima.core.search.framework

Examples of aima.core.search.framework.Search


    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

  public void testUniformCostSuccesfulSearch() throws Exception {
    Problem problem = new Problem(new NQueensBoard(8),
        NQueensFunctionFactory.getIActionsFunction(),
        NQueensFunctionFactory.getResultFunction(),
        new NQueensGoalTest());
    Search search = new UniformCostSearch();
    SearchAgent agent = new SearchAgent(problem, search);

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

    Assert.assertEquals(8, actions.size());
View Full Code Here

  public void testUniformCostUnSuccesfulSearch() throws Exception {
    Problem problem = new Problem(new NQueensBoard(3),
        NQueensFunctionFactory.getIActionsFunction(),
        NQueensFunctionFactory.getResultFunction(),
        new NQueensGoalTest());
    Search search = new UniformCostSearch();
    SearchAgent agent = new SearchAgent(problem, search);

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

    Assert.assertEquals(0, actions.size());
View Full Code Here

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

    Search search = new UniformCostSearch();
    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

    Problem problem = new Problem("start",
        MapFunctionFactory.getActionsFunction(map),
        MapFunctionFactory.getResultFunction(), new DefaultGoalTest(
            "goal"), new MapStepCostFunction(map));

    Search search = new UniformCostSearch();
    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

            .get(i)), wayFilter);
        HeuristicFunction hf = createHeuristicFunction(toRNode,
            waySelection);
        Problem problem = createProblem(fromRNode, toRNode, mapData,
            wayFilter, ignoreOneways, waySelection);
        Search search = new AStarSearch(new GraphSearch(), hf);
        List<Action> actions = search.search(problem);
        if (actions.isEmpty())
          break;
        for (Object action : actions) {
          if (action instanceof OsmMoveAction) {
            OsmMoveAction a = (OsmMoveAction) action;
View Full Code Here

        MapFunctionFactory.getResultFunction(), new DualMapGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST,
            SimplifiedRoadMapOfPartOfRomania.HIRSOVA),
        new MapStepCostFunction(romaniaMap));

    Search search = new BreadthFirstSearch(new GraphSearch());

    SearchAgent agent = new SearchAgent(problem, search);
    Assert.assertEquals(
        "[Action[name==moveTo, location==Sibiu], Action[name==moveTo, location==Fagaras], Action[name==moveTo, location==Bucharest], Action[name==moveTo, location==Urziceni], Action[name==moveTo, location==Hirsova]]",
        agent.getActions().toString());
View Full Code Here

  public void testBreadthFirstSuccesfulSearch() throws Exception {
    Problem problem = new Problem(new NQueensBoard(8),
        NQueensFunctionFactory.getIActionsFunction(),
        NQueensFunctionFactory.getResultFunction(),
        new NQueensGoalTest());
    Search search = new BreadthFirstSearch(new TreeSearch());
    SearchAgent agent = new SearchAgent(problem, search);
    List<Action> actions = agent.getActions();
    assertCorrectPlacement(actions);
    Assert.assertEquals("1665",
        agent.getInstrumentation().getProperty("nodesExpanded"));
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.