Пример #1
0
  ExecStatus
  ChannelBool<View>::propagate(Space& home, const ModEventDelta&) {
    running = true;
    if (zeros.size() > 0) {
      BndSetRanges zi(zeros);
      GECODE_ME_CHECK(y.excludeI(home, zi));
      zeros.init(home);
    }
    if (ones.size() > 0) {
      BndSetRanges oi(ones);
      GECODE_ME_CHECK(y.includeI(home, oi));
      ones.init(home);
    }
    running = false;

    if (delta.glbMin() != 1 || delta.glbMax() != 0) {
      if (!delta.glbAny()) {
        for (int i=delta.glbMin(); i<=delta.glbMax(); i++)
          GECODE_ME_CHECK(x[i].one(home));
      } else {
        GlbRanges<View> glb(y);
        for (Iter::Ranges::ToValues<GlbRanges<View> > gv(glb); gv(); ++gv) {
          GECODE_ME_CHECK(x[gv.val()].one(home));
        }
      }
    }
    if (delta.lubMin() != 1 || delta.lubMax() != 0) {
      if (!delta.lubAny()) {
        for (int i=delta.lubMin(); i<=delta.lubMax(); i++)
          GECODE_ME_CHECK(x[i].zero(home));
      } else {
        int cur = 0;
        for (LubRanges<View> lub(y); lub(); ++lub) {
          for (; cur < lub.min(); cur++) {
            GECODE_ME_CHECK(x[cur].zero(home));
          }
          cur = lub.max() + 1;
        }
        for (; cur < x.size(); cur++) {
          GECODE_ME_CHECK(x[cur].zero(home));
        }
      }
    }

    new (&delta) SetDelta();

    return y.assigned() ? home.ES_SUBSUMED(*this) : ES_FIX;
  }
Пример #2
0
/** Abstraction function.
 * @param[in]  values      Subset of the concrete domain
 * @retval     SInterval    Abstract value corresponding to the least
 *                         upperBound of the concrete values
 */
SInterval SInterval::alpha(vector<int> values)
{
  vector<int>::iterator it;
  SInterval a;
  
  a = alpha(values[0]);
  for(it = values.begin(); it != values.end(); ++it){
    a = lub(a, alpha(*it));
  }
  
  return a;
}
Пример #3
0
int main(int argc, char*argv[]){
  int failed=0;
  uint32_t i;
  uint32_t result;
  uint32_t out;
  int aaa[1024];
  int k=0;
  int m=0;
  int del = 0;
  int table[128];

  if(argc < 4){
   printf("few args!!\n");
   return 1;
  }

  i=0;
  while(i<128){
    table[i]=0;
    i++;
  }
  int offset = atoi(argv[1]);
  int offset_term = atoi(argv[2]);
  i=(127<<23) + (offset << 13);

  int j=0 - (atoi(argv[3]));
  int dist=1000;
  int best=0;

  while(offset < offset_term){

    dist=1000;
    j=0 - (atoi(argv[3]));

    while(j < atoi(argv[3]) + 1){

      k=0;
      i=(127<<23) + (offset << 13);

      while(k < 8192*1024){
	result=finv_s(i);
	out = finv(i,j);
	del = out - result;
	/*if(del > 4 || del < -4){
	  printf("offset: %d\n",offset);
	  printf("del: %d\n",del);
	  printbin(i);
	  printbin(out);
	  printbin(result);
	  return 0;
	  }*/
	table[del+64] = table[del+64]+1;
	k++;
	i++;
      }
      
      printtable(table);
      return 1;
      

      if(distri(table) < dist){
	best = j;
	dist = distri(table);
      }

      m=0;
      while(m<128){
	table[m]=0;
	m++;
      }
      
      j++;
    }
    
    k=0;
    i=(127<<23) + (offset << 13);
     while(k < 8192){
	result=finv_s(i);
	out = finv(i,best);
	del = out - result;
	table[del+64] = table[del+64]+1;
	k++;
	i++;
      }

     //print23bin(ctou(dummy[offset]));
     //printtable(table);
     //printf("%d\n",lub(table));
     aaa[offset] = 0 - ((lub(table)+glb(table)) /2);
     /*m=0;
     while(m<128){
       table[m]=0;
       m++;
     }*/
    
     if(dist < 10){
       fprintf(stderr,"clear: offset=%d,dist=%d,exp=%d,best=%d,glb=%d,lub=%d\n",offset,dist,aaa[offset],best,glb(table),lub(table));
    }else{
       fprintf(stderr,"FAILED...: offset=%d,dist=%d,exp=%d,best=%d,glb=%d,lub=%d\n",offset,dist,aaa[offset],best,glb(table),lub(table));
      failed++;
      }
    fprintf(stderr,"sinchoku...%d/%d\n",offset-atoi(argv[1]),atoi(argv[2])-atoi(argv[1]));
    incdecprint2(dummy2,best,offset);

      m=0;
      while(m<128){
	table[m]=0;
	m++;
      }

      offset++;
  }
  offset=atoi(argv[1]);
  while(offset < atoi(argv[2])){
    incdecprint(dummy,aaa[offset],offset);
    offset++;
  }

	//printf("best case: %d dist: %d\n",best,dist);
  fprintf(stderr,"failed cases: %d/%d\n",failed,atoi(argv[2])-atoi(argv[1]));
  
  return 0;
}