Exemplo n.º 1
0
  public boolean leftChild(PrimitiveConstraint choice, boolean status) {

    boolean returnCode = true;

    if (exitChildListeners != null) {
      boolean code = false;
      for (int i = 0; i < exitChildListeners.length; i++)
        code |= exitChildListeners[i].leftChild(choice, status);
      returnCode = code;
    }

    currentSearchNode = searchStack.pop();
    //		SearchNode previousSearchNode = currentSearchNode;

    if (!status && returnCode) {

      currentSearchNode = new SearchNode();
      // currentSearchNode.v = var;

      //			if (previousSearchNode.dom instanceof JaCoP.core.IntDomain)
      //				currentSearchNode.dom = ((IntDomain)previousSearchNode.dom).subtract( value );
      //			else if (previousSearchNode.dom instanceof JaCoP.set.core.SetDomain)
      //				currentSearchNode.dom = ((SetDomain)previousSearchNode.dom).subtract( value, value );

      // currentSearchNode.val = value;
      currentSearchNode.id = searchNodeId++;
      currentSearchNode.equal = false;
      currentSearchNode.c = choice;
      currentSearchNode.previous = searchStack.peek().id;

      searchStack.push(currentSearchNode);
    }

    return returnCode;
  }
Exemplo n.º 2
0
  public PrimitiveConstraint getChoiceConstraint(int index) {

    PrimitiveConstraint c = select.getChoiceConstraint(index);

    if (c == null) {

      generateSuccessNode(currentSearchNode.id);
      generateVisualizationNode(currentSearchNode.id, true);

    } else {

      currentSearchNode = new SearchNode();
      currentSearchNode.c = c;
      currentSearchNode.id = searchNodeId++;
      currentSearchNode.previous = searchStack.peek().id;

      searchStack.push(currentSearchNode);
    }

    return c;
  }