Exemple #1
0
PAData::PAData(QString &fileName, TSDataPtr ts_ptr)
{
    this->dataType = PAFILE;
    this->associatedData = ts_ptr;

    CODEBOOK *cb = static_cast<CODEBOOK*>(ts_ptr.data()->getData());
    ReadPartitioning(fileName.toLatin1().data(), &this->partition, cb);
    setFileName(fileName, "pa");
}
Exemple #2
0
//modify by QP on 2k8-4-7 
//change the function ReadInitialCBorPA( )
//add two parameters int Minclus and Maxclus,delete int clus
//Minclus -- Min number of clusters
//Maxclus -- Max number of clusters
int ReadInitialCBorPA(char *InName, int Minclus, int Maxclus, TRAININGSET *pTS, 
CODEBOOK *pCB, PARTITIONING *pP) 
{
  int useInitial = 0;
  
  if (*InName)  /* we use initial codebook/partitioning */
  {
    switch (DetermineCBFileType(InName)) {
      case TSFILE: case CBFILE:
        ReadCodebook(InName, pCB);
        useInitial = 1;
        //modify by QP on 2k8-4-7 
		//If we use initial ones, we just need to judge the size of codebook/
		//training set is in the range: [Minclus, Maxclus]
		if (BookSize(pCB) < Minclus || BookSize(pCB) > Maxclus )
        {
          ErrorMessage("\nERROR: Number of vectors in initial codebook ");
          ErrorMessage("(%d) <> number of clusters ", BookSize(pCB));
          ErrorMessage("(%d)(%d)!\n\n", Minclus, Maxclus);
          FreeCodebook(pTS);
          FreeCodebook(pCB);
          ExitProcessing(FATAL_ERROR);
        }
        
        CreateNewPartitioning(pP, pTS, BookSize(pCB));
        break;
        
      case PAFILE:
        ReadPartitioning(InName, pP, pTS);
        useInitial = 2;
        
        //modify by QP on 2k8-4-7 
		//judge the size of partitioning is in the range: [Minclus, Maxclus]
        if (PartitionCount(pP)<Minclus || PartitionCount(pP) > Maxclus)
        {
          ErrorMessage("\nERROR: Number of partitions in initial partitioning ");
          ErrorMessage("(%d) <> number of clusters ", PartitionCount(pP));
          ErrorMessage("(%d)(%d)!\n\n", Minclus, Maxclus);
          FreeCodebook(pTS);
          FreePartitioning(pP);
          ExitProcessing(FATAL_ERROR);
        }
        
        CreateNewCodebook(pCB, PartitionCount(pP), pTS);
        break;
        
      case NOTFOUND:
        ErrorMessage("\nERROR: Type of initial codebook/partitioning file "
            "%s is unidentified!\n\n", InName);
        FreeCodebook(pTS);
        ExitProcessing(FATAL_ERROR);
        break;
    }      
  }
  else  /* we don't use initial codebook/partitioning */
  {
 //   CreateNewCodebook(pCB, clus, pTS);
 //   CreateNewPartitioning(pP, pTS, clus);
    useInitial = 0;
  }
  
  return useInitial;
}