⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.cpp

📁 关联规则挖掘数据产生程序.VISUAL C++ 可产生满足要求的挖掘数据.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      }
      else if (strcmp(argv[arg_pos], "-nlevels") == 0) {
	par.nlevels = atof(argv[++arg_pos]);
	cat_fname(".nlevels_", argv[arg_pos]);
	arg_pos++;
	if (par.nlevels < 1) err_msg("nlevels must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-fanout") == 0) {
	par.fanout = atof(argv[++arg_pos]);
	cat_fname(".fanout_", argv[arg_pos]);
	arg_pos++;
	if (par.fanout < 1) err_msg("fanout must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-depth") == 0) {
	par.depth_ratio = atof(argv[++arg_pos]);
	cat_fname(".depth_", argv[arg_pos]);
	arg_pos++;
	if (par.depth_ratio <= 0) err_msg("fanout must be > 0\n");
	continue;
      }

      else if (strcmp(argv[arg_pos], "-npats") == 0) {
	par.lits.npats = atoi(argv[++arg_pos]);
	cat_fname(".npats_", argv[arg_pos]);
	arg_pos++;
	if (par.lits.npats < 1) err_msg("npats must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-patlen") == 0) {
	par.lits.patlen = atof(argv[++arg_pos]);
	cat_fname(".patlen_", argv[arg_pos]);
	arg_pos++;
	if (par.lits.patlen <= 0) err_msg("patlen must be > 0\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-corr") == 0) {
	par.lits.corr = atof(argv[++arg_pos]);
	cat_fname(".corr_", argv[arg_pos]);
	arg_pos++;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-conf") == 0) {
	par.lits.conf = atof(argv[++arg_pos]);
	cat_fname(".conf_", argv[arg_pos]);
	arg_pos++;
	if (par.lits.conf > 1 || par.lits.conf < 0) 
	  err_msg("conf must be between 0 and 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-fname") == 0) {
        strcpy(data_file, argv[++arg_pos]);
        strcat(data_file, ".data");
        strcpy(pat_file, argv[arg_pos]);
        strcat(pat_file, ".pat");
        strcpy(tax_file, argv[arg_pos++]);
        strcat(tax_file, ".tax");
        userfile = true;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-ascii") == 0) {
	par.ascii = true;
	cat_fname(".ascii", "");
	arg_pos++;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-randseed") == 0) {
	par.seed = atoi(argv[++arg_pos]);
	arg_pos++;
	if (par.seed >= 0)
	  err_msg("randseed must be negative.\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-version") == 0) {
	cout << VERSION << endl;
	exit(0);
      }
      else {
	command_line(par);
      }
    }  // end while

  par.calc_values();
}


void get_args(SeqPar &par, int argc, char **argv)
{
  int arg_pos = 2;
  
  strcpy(data_file, "data");
  strcpy(pat_file, "pat");
  strcpy(tax_file, "tax");
  while (arg_pos < argc)
    {
      if (strcmp(argv[arg_pos], "-ncust") == 0) {
	par.ncust = 1000 * atof(argv[++arg_pos]);
	cat_fname(".ncust_", argv[arg_pos]);
	arg_pos++;
	if (par.ncust < 1) err_msg("ntrans must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-slen") == 0) {
	par.slen = atof(argv[++arg_pos]);
	cat_fname(".slen_", argv[arg_pos]);
	arg_pos++;
	if (par.slen < 1) err_msg("slen must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-tlen") == 0) {
	par.tlen = atof(argv[++arg_pos]);
	cat_fname(".tlen_", argv[arg_pos]);
	arg_pos++;
	if (par.tlen < 1) err_msg("tlen must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-nitems") == 0) {
	par.nitems = 1000 * atof(argv[++arg_pos]);
	cat_fname(".nitems_", argv[arg_pos]);
	arg_pos++;
	if (par.nitems < 1) err_msg("nitems must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-rept") == 0) {
	par.rept = atof(argv[++arg_pos]);
	cat_fname(".rept_", argv[arg_pos]);
	arg_pos++;
	if (par.rept < 0 || par.rept > 1) 
	  err_msg("repetition-level must be between 0 and 1\n");
	continue;
      }

      else if (strcmp(argv[arg_pos], "-seq.npats") == 0) {
	par.lseq.npats = atoi(argv[++arg_pos]);
	cat_fname(".seq.npats_", argv[arg_pos]);
	arg_pos++;
	if (par.lseq.npats < 1) err_msg("npats must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-seq.patlen") == 0) {
	par.lseq.patlen = atof(argv[++arg_pos]);
	cat_fname(".seq.patlen_", argv[arg_pos]);
	arg_pos++;
	if (par.lseq.patlen <= 0) err_msg("patlen must be > 0\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-seq.corr") == 0) {
	par.lseq.corr = atof(argv[++arg_pos]);
	cat_fname(".seq.corr_", argv[arg_pos]);
	arg_pos++;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-seq.conf") == 0) {
	par.lseq.conf = atof(argv[++arg_pos]);
	cat_fname(".seq.conf_", argv[arg_pos]);
	arg_pos++;
	if (par.lseq.conf > 1 || par.lseq.conf < 0) 
	  err_msg("conf must be between 0 and 1\n");
	continue;
      }

      else if (strcmp(argv[arg_pos], "-lit.npats") == 0) {
	par.lits.npats = atoi(argv[++arg_pos]);
	cat_fname(".lit.npats_", argv[arg_pos]);
	arg_pos++;
	if (par.lits.npats < 1) err_msg("npats must be >= 1\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-lit.patlen") == 0) {
	par.lits.patlen = atof(argv[++arg_pos]);
	cat_fname(".lit.patlen_", argv[arg_pos]);
	arg_pos++;
	if (par.lits.patlen <= 0) err_msg("patlen must be > 0\n");
	continue;
      }
      else if (strcmp(argv[arg_pos], "-lit.corr") == 0) {
	par.lits.corr = atof(argv[++arg_pos]);
	cat_fname(".lit.corr_", argv[arg_pos]);
	arg_pos++;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-lit.conf") == 0) {
	par.lits.conf = atof(argv[++arg_pos]);
	cat_fname(".lit.conf_", argv[arg_pos]);
	arg_pos++;
	if (par.lits.conf > 1 || par.lits.conf < 0) 
	  err_msg("conf must be between 0 and 1\n");
	continue;
      }

      else if (strcmp(argv[arg_pos], "-fname") == 0) {
        strcpy(data_file, argv[++arg_pos]);
        strcat(data_file, ".data");
        strcpy(pat_file, argv[arg_pos]);
        strcat(pat_file, ".pat");
        strcpy(tax_file, argv[arg_pos++]);
        strcat(tax_file, ".tax");
        userfile = true;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-ascii") == 0) {
	par.ascii = true;
	cat_fname(".ascii", "");
	arg_pos++;
	continue;
      }
      else if (strcmp(argv[arg_pos], "-version") == 0) {
	cout << VERSION << endl;
	exit(0);
      }
      else {
	command_line(par);
      }
    }  // end while
}


float gammln(float xx)
{
  double x,tmp,ser;
  static double cof[6]={76.18009173,-86.50532033,24.01409822,
			-1.231739516,0.120858003e-2,-0.536382e-5};
  int j;
  
  x=xx-1.0;
  tmp=x+5.5;
  tmp -= (x+0.5)*log(tmp);
  ser=1.0;
  for (j=0;j<=5;j++) {
    x += 1.0;
    ser += cof[j]/x;
  }
  return -tmp+log(2.50662827465*ser);
}



#define IA 16807
#define IM 2147483647
#define AM (1.0/IM)
#define IQ 127773
#define IR 2836
#define MASK 123459876

#define NTAB 32
#define NDIV (1+(IM-1)/NTAB)
#define EPS 1.2e-7
#define RNMX (1.0-EPS)


float ran0(long &idum)
// "Minimal" random number generator of Park and Miller with
// Bays-Durham shuffle and added safeguards. Returns a uniform random
// deviate between 0.0 and 1.0. Set or reset idum to any integer value
// (except the unlikely value MASK) to initialize the sequence; idum
// must not be altered between calls for successive deviates in a sequence. 
{
  long k;
  float ans;
  
  idum ^= MASK;			  // XORing with MASK allows use of 0 and
  k = idum/IQ;			  //     other simple bit patterns for idum.
  idum = IA * (idum-k*IQ) - IR*k; // Compute idum = (IA*idum) % IM without
  if (idum < 0) idum += IM;	  //     overflows by Schrage's method.
  ans = AM * idum;		  // Convert idum to a floating result.
  idum ^= MASK;			  // Unmask before return.
  return ans;
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -