Ejemplo n.º 1
0
  private void playEvents() {
    up2date = true;
    int currentC = curChunk.get();
    int currentI = nextTop.get();
    //        long time = -System.nanoTime();
    //        long count = 0;
    for (int chunk = 0; chunk <= currentC; chunk++) {
      int to = (chunk == currentC ? currentI : CHUNK_SIZE);
      for (int cell = 0; cell < to; cell++) {
        IntVar var = varChunks[chunk][cell];
        EventType etype = masChunks[chunk][cell];
        ICause cause = cauChunks[chunk][cell];
        int one = val1Chunks[chunk][cell];
        int two = val2Chunks[chunk][cell];
        int three = val3Chunks[chunk][cell];
        //                System.out.printf("%s %s %d %d %d - %s\n", var, etype, one, two, three,
        // cause);
        //                count++;
        switch (etype) {
          case REMOVE:
            super.removeValue(var, one, cause);
            break;
          case INSTANTIATE:
            super.instantiateTo(var, one, cause, two, three);
            break;
          case INCLOW:
            super.updateLowerBound(var, one, two, cause);
            break;
          case DECUPP:
            super.updateUpperBound(var, one, two, cause);
            break;
          case FULL_PROPAGATION:
            Propagator prop = (Propagator) cause;
            BoolVar bVar = (BoolVar) var;
            super.activePropagator(bVar, prop);
            break;
          default:
            throw new UnsupportedOperationException("Unknown type " + etype);
        }
      }
    }
    //        time += System.nanoTime();
    //        System.out.printf("depth %d, lazy %.3f ", count, time / (1000 * 1000f));

  }
Ejemplo n.º 2
0
 private void pushEvent(IntVar var, ICause cause, EventType mask, int one, int two, int three) {
   assert cause != Cause.Null : "cause null";
   int currentC = curChunk.get();
   int currentI = nextTop.add(1);
   if (currentI > CHUNK_SIZE) {
     currentC = curChunk.add(1);
     int l = varChunks.length;
     if (currentC == l) {
       increase(l);
     }
     nextTop.set(1);
     currentI = 0;
   } else {
     currentI--;
   }
   varChunks[currentC][currentI] = var;
   cauChunks[currentC][currentI] = cause;
   masChunks[currentC][currentI] = mask;
   val1Chunks[currentC][currentI] = one;
   val2Chunks[currentC][currentI] = two;
   val3Chunks[currentC][currentI] = three;
   up2date = false;
 }