Package aima.core.search.framework

Examples of aima.core.search.framework.Node


   */
  public List<Action> search(Problem p) throws Exception {
    clearInstrumentation();
    // return RECURSIVE-DLS(MAKE-NODE(INITIAL-STATE[problem]), problem,
    // limit)
    return recursiveDLS(new Node(p.getInitialState()), p, limit);
  }
View Full Code Here


    // 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;
        Node prpNode = null;
        if (opFrontier.containsNodeBasedOn(rpNode.getState())) {
          popNode = opFrontier.getNodeBasedOn(rpNode.getState());
          prpNode = rpNode;
        } else if (rpFrontier.containsNodeBasedOn(opNode.getState())) {
          popNode = opNode;
View Full Code Here

   */
  public List<Action> search(Problem p) throws Exception {
    clearInstrumentation();
    // return RECURSIVE-DLS(MAKE-NODE(INITIAL-STATE[problem]), problem,
    // limit)
    return recursiveDLS(new Node(p.getInitialState()), p, limit);
  }
View Full Code Here

  public List<Action> search(Problem p) throws Exception {
    clearInstrumentation();
    outcome = SearchOutcome.FAILURE;
    lastState = null;
    // current <- MAKE-NODE(problem.INITIAL-STATE)
    Node current = new Node(p.getInitialState());
    Node next = null;
    List<Action> ret = new ArrayList<Action>();
    // for t = 1 to INFINITY do
    int timeStep = 0;
    while (!CancelableThread.currIsCanceled()) {
      // temperature <- schedule(t)
View Full Code Here

  public List<Action> search(Problem p) throws Exception {
    clearInstrumentation();
    outcome = SearchOutcome.FAILURE;
    lastState = null;
    // current <- MAKE-NODE(problem.INITIAL-STATE)
    Node current = new Node(p.getInitialState());
    Node neighbor = null;
    // loop do
    while (!CancelableThread.currIsCanceled()) {
      List<Node> children = expandNode(current, p);
      // neighbor <- a highest-valued successor of current
      neighbor = getHighestValuedNodeFrom(children, p);
View Full Code Here

  // PRIVATE METHODS
  //

  private Node getHighestValuedNodeFrom(List<Node> children, Problem p) {
    double highestValue = Double.NEGATIVE_INFINITY;
    Node nodeWithHighestValue = null;
    for (int i = 0; i < children.size(); i++) {
      Node child = (Node) children.get(i);
      double value = getValue(child);
      if (value > highestValue) {
        highestValue = value;
        nodeWithHighestValue = child;
      }
View Full Code Here

    List<Action> actions = new ArrayList<Action>();

    clearInstrumentation();

    // RBFS(problem, MAKE-NODE(INITIAL-STATE[problem]), infinity)
    Node n = new Node(p.getInitialState());
    SearchResult sr = rbfs(p, n, evaluationFunction.f(n), INFINITY, 0);
    if (sr.getOutcome() == SearchResult.SearchOutcome.SOLUTION_FOUND) {
      Node s = sr.getSolution();
      actions = SearchUtils.actionsFromNodes(s.getPathFromRoot());
      setPathCost(s.getPathCost());
    }

    // Empty List can indicate already at Goal
    // or unable to find valid set of actions
    return actions;
View Full Code Here

*/
public class NodeTest {

  @Test
  public void testRootNode() {
    Node node1 = new Node("state1");
    Assert.assertTrue(node1.isRootNode());
    Node node2 = new Node("state2", node1, null, 1.0);
    Assert.assertTrue(node1.isRootNode());
    Assert.assertFalse(node2.isRootNode());
    Assert.assertEquals(node1, node2.getParent());
  }
View Full Code Here

    Assert.assertEquals(node1, node2.getParent());
  }

  @Test
  public void testGetPathFromRoot() {
    Node node1 = new Node("state1");
    Node node2 = new Node("state2", node1, null, 1.0);
    Node node3 = new Node("state3", node2, null, 1.0);
    List<Node> path = node3.getPathFromRoot();
    Assert.assertEquals(node1, path.get(0));
    Assert.assertEquals(node2, path.get(1));
    Assert.assertEquals(node3, path.get(2));
  }
View Full Code Here

TOP

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

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.