private void updateSpecialNodes() {
   for (int i = 0; i < nbNodes; i++) {
     if (graph[i].cardinality() == 0) sinkNodes.set(i, true);
     else sinkNodes.set(i, false);
     if (revGraph[i].cardinality() == 0) srcNodes.set(i, true);
     else srcNodes.set(i, false);
   }
 }
 /**
  * Constructs a new domain for the specified variable and bounds.
  *
  * @param v The involved variable.
  * @param a Minimal value.
  * @param b Maximal value.
  * @param full indicate if the initial bitSetDomain is full or empty (env or ker)
  * @param environment
  */
 public BitSetEnumeratedDomain(SetVar v, int a, int b, boolean full, IEnvironment environment) {
   capacity = b - a + 1; // number of entries
   this.offset = a;
   if (full) size = environment.makeInt(capacity);
   else size = environment.makeInt(0);
   contents = environment.makeBitSet(capacity);
   if (full) {
     for (int i = 0; i < capacity; i++) contents.set(i);
   }
   delatDom = new BitSetDeltaDomain(capacity, offset);
 }
 private IStateBitSet getDesc(int i, int j, IStateBitSet[] graph) {
   // retrieve the set of reachable nodes from i in the graph
   needUpdate = true;
   Stack<Integer> stack = new Stack<Integer>();
   IStateBitSet reached = solver.getEnvironment().makeBitSet(nbNodes);
   stack.push(i);
   while (!stack.isEmpty()) {
     int a = stack.pop();
     for (int b = graph[a].nextSetBit(0); b >= 0; b = graph[a].nextSetBit(b + 1)) {
       if (!stack.contains(b) && !reached.get(b)) {
         reached.set(b, true);
         if (b == j) {
           needUpdate = false;
           return reached;
         } else stack.push(b);
       }
     }
   }
   return reached;
 }
 public BitSetEnumeratedDomain(
     SetVar v, int[] sortedValues, boolean full, IEnvironment environment) {
   int a = sortedValues[0];
   int b = sortedValues[sortedValues.length - 1];
   capacity = b - a + 1; // number of entries
   this.offset = a;
   if (full) {
     size = environment.makeInt(sortedValues.length);
   } else {
     size = environment.makeInt(0);
   }
   contents = environment.makeBitSet(capacity);
   if (full) {
     // TODO : could be improved...
     for (int sortedValue : sortedValues) {
       contents.set(sortedValue - a);
     }
   }
   delatDom = new BitSetDeltaDomain(capacity, offset);
 }
Beispiel #5
0
  public BitsetXYSumView(IntVar a, IntVar b, Solver solver) {
    super(a, b, solver);
    int lbA = A.getLB();
    int ubA = A.getUB();
    int lbB = B.getLB();
    int ubB = B.getUB();
    OFFSET = lbA + lbB;
    VALUES = solver.getEnvironment().makeBitSet((ubA + ubB) - (lbA + lbB) + 1);

    DisposableRangeIterator itA = A.getRangeIterator(true);
    DisposableRangeIterator itB = B.getRangeIterator(true);
    while (itA.hasNext()) {
      itB.bottomUpInit();
      while (itB.hasNext()) {
        VALUES.set(itA.min() + itB.min() - OFFSET, itA.max() + itB.max() - OFFSET + 1);
        itB.next();
      }
      itB.dispose();
      itA.next();
    }
    itA.dispose();
    SIZE.set(VALUES.cardinality());
  }
 private void updateSpecialNodes(int u, int v) {
   if (graph[u].cardinality() == 0) sinkNodes.set(u, true);
   else sinkNodes.set(u, false);
   if (revGraph[v].cardinality() == 0) srcNodes.set(v, true);
   else srcNodes.set(v, false);
 }
 private void addIndex(int i) {
   contents.set(i);
   delatDom.remove(i + offset);
   if (!contents.get(i)) LOGGER.severe("etrange etrange");
   size.add(1);
 }