Example #1
0
 //modify by QP on 2k8-4-7
//add two parameters 
//int dis; int cri; for distance function and criteria function seperately
TRAININGSET CheckParameters(char *TSName, char *CBName, char *PAName, 
char *InName, int Minclus,int Maxclus, int ow) {
  TRAININGSET TS;
  
  /* input training set doesn't exist */
  if (!ExistFile(TSName)) 
  {
    ErrorMessage("\nERROR: Input training set doesn't exist: "
        "%s\n\n", TSName);
    ExitProcessing(FATAL_ERROR);
  }
    
  /* result codebook file exists and we are told not to overwrite */
  if (ExistFile(CBName) && !ow) 
  {
    ErrorMessage("\nERROR: Result codebook already exists: "
        "%s\n\n", CBName);
    ExitProcessing(FATAL_ERROR);
  }

  /* result partitioning file exists and we are told not to overwrite */
  if (*PAName && ExistFile(PAName) && !ow) 
  {
    ErrorMessage("\nERROR: Result partitioning already exists: "
        "%s\n\n", PAName);
    ExitProcessing(FATAL_ERROR);
  }
  
  /* initial codebook / partitioning doesn't exist */
  if (*InName && !DetermineFileName(InName))
  {
    ErrorMessage("\nERROR: Initial codebook/partitioning doesn't exist: %s\n\n", InName);
    ExitProcessing(FATAL_ERROR);
  }
   //add by QP on 2k8-4-7
  //verify whether Max is bigger than min; make sure the range is ok
    if (Maxclus < Minclus ) 
	{
		ErrorMessage("Bad range: %i < %i.\n", Maxclus, Minclus);
		ExitProcessing(FATAL_ERROR);
    } 
  
  ReadTrainingSet(TSName, &TS);

 
  //add by QP on 2k7-11-7  
  //the size of training set should be at least more than min codebook
  /* result codebook cannot contain more vectors than training set */
  if (BookSize(&TS) < Minclus)
  {
    ErrorMessage("\nERROR: Number of vectors in training set ");
    ErrorMessage("(%d) < Min number of clusters ", BookSize(&TS));
    ErrorMessage("(%d%d)!\n\n", Minclus, Maxclus);
    FreeCodebook(&TS);
    ExitProcessing(FATAL_ERROR);
  }
  
  return TS;
}  /* CheckParameters() */
Example #2
0
TSData::TSData(QString &fileName)
{
    this->dataType = TSFILE;
    ReadTrainingSet(fileName.toLatin1().data(), &this->trainingSet);
    setFileName(fileName, "ts");
}