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

📄 mssriicc.cc

📁 一种聚类算法,名字是cocluster
💻 CC
📖 第 1 页 / 共 5 页
字号:
    for (int rc = 0; rc < numRowCluster; rc++)      rowAR[rc] = new double[numCol];  }  computeRowCentroid(isReversed);	// rowCentroid, in R^(numRowCluster * numCol)  normalizeRowCentroid();  computeColCentroid(isReversed);	// colCentroid, in R^(numRow * numColCluster)  normalizeColCentroid();  computeRowAR();			// rowAR = mA^R = mR'A - mR'ACC', in R^(numRowCluster * numCol)  computeQuality4RowAR();		// rowQuality4Compressed[r] = sum_j(mA^R_rj)^2 = sum_j(m_r^(-1/2) * A^R_rj)^2   for (int r = 0; r < numRow; r++){    tempRowCL = rowCL[r];    minCL = tempRowCL;    if (isReversed[r]){      tempIsReversed = true;      computeRowAP(r, isReversed);	// rowAP_i = (A - ACC')_i, in R^(1*numCol)      minDistance = MY_DBL_MAX;      for (int rc = 0; rc < numRowCluster; rc++)        if (rowCS[rc] > 0){          tempDistance = rowDistance(r, rc); 	  updateVariable(minDistance, minCL, tempDistance, rc);        }      isReversed[r] = false;       computeRowAP(r);			// rowAP_i = (A - ACC')_i, in R^(1*numCol)      for (int rc = 0; rc < numRowCluster; rc++)        if (rowCS[rc] > 0){          tempDistance = rowDistance(r, rc); 	  updateVariable(minDistance, minCL, tempIsReversed, tempDistance, rc, false);        }    } else {				// (i.e., isReversed[r] == false)      tempIsReversed = false;      computeRowAP(r);			// rowAP_i = (A - ACC')_i, in R^(1*numCol)      minDistance = MY_DBL_MAX;      for (int rc = 0; rc < numRowCluster; rc++)        if (rowCS[rc] > 0){          tempDistance = rowDistance(r, rc);           updateVariable(minDistance, minCL, tempDistance, rc);        }      isReversed[r] = true;      computeRowAP(r, isReversed);	// rowAP_i = (A - ACC')_i, in R^(1*numCol)      for (int rc = 0; rc < numRowCluster; rc++)        if (rowCS[rc] > 0){	  tempDistance = rowDistance(r, rc);          updateVariable(minDistance, minCL, tempIsReversed, tempDistance, rc, true);        }    }    if (minCL != tempRowCL)      rowClusterChange++;    rowCL[r] = minCL;    isReversed[r] = tempIsReversed;  }  if (rowAR != NULL){    for (int rc = 0; rc < numRowCluster; rc++)      delete [] rowAR[rc];    delete [] rowAR;    rowAR = NULL;  }  checkDumpLevel4NumOfChange("row(s)", rowClusterChange);  checkDumpLevel4ReversedRow();/*cout << "I am here..." << endl;computeObjectiveFunction4Normalized(Acompressed, isReversed);		// not working!!!checkDumpLevel4BatchUpdate("row", numIteration);*/}void MssrIIcc::reassignCC(){  int colClusterChange = 0;  int tempColCL, minCL;  double tempDistance, minDistance;  if (colAC == NULL){    colAC = new double*[numColCluster];    for (int cc = 0; cc < numColCluster; cc++)      colAC[cc] = new double[numRow];  }  computeRowCentroid();			// rowCentroid, in R^(numRowCluster * numCol)  normalizeRowCentroid();  computeColCentroid();			// colCentroid, in R^(numRow * numColCluster)  normalizeColCentroid();  computeColAC();			// colAC = nA^C = nAC - nRR'AC, in R^(numRow * numColCluster)  computeQuality4ColAC();		// colQuality4Compressed[c] = sum_i(nA^C_ic)^2 = sum_i(n_c^(-1/2) * A^C_ic)^2  for (int c = 0; c < numCol; c++){    tempColCL = colCL[c];    minCL = tempColCL;    computeColAP(c);			// colAP_j = (A - RR'A)_j, in R^(1*numRow)    minDistance = MY_DBL_MAX;    for (int cc = 0; cc < numColCluster; cc++){      if (colCS[cc] > 0){        tempDistance = colDistance(c, cc); 	updateVariable(minDistance, minCL, tempDistance, cc);      }    }    if (minCL != tempColCL)      colClusterChange++;    colCL[c] = minCL;  }  if (colAC != NULL){    for (int cc = 0; cc < numColCluster; cc++)      delete [] colAC[cc];    delete [] colAC;    colAC = NULL;  }  checkDumpLevel4NumOfChange("col(s)", colClusterChange);}  void MssrIIcc::reassignCC4Variation(){  int colClusterChange = 0;  int tempColCL, minCL;  double tempDistance, minDistance;  if (colAC == NULL){    colAC = new double*[numColCluster];    for (int cc = 0; cc < numColCluster; cc++)      colAC[cc] = new double[numRow];  }// The following two lines are commented out, to make use of the previous rowCentroid!!!//  computeRowCentroid();			// rowCentroid, in R^(numRowCluster * numCol)//  normalizeRowCentroid();  computeColCentroid();			// colCentroid, in R^(numRow * numColCluster)  normalizeColCentroid();  computeColAC();			// colAC = nA^C = nAC - nRR'AC, in R^(numRow * numColCluster)  computeQuality4ColAC();		// colQuality4Compressed[c] = sum_i(nA^C_ic)^2 = sum_i(n_c^(-1/2) * A^C_ic)^2  for (int c = 0; c < numCol; c++){    tempColCL = colCL[c];    minCL = tempColCL;    computeColAP(c);			// colAP_j = (A - RR'A)_j, in R^(1*numRow)    minDistance = MY_DBL_MAX;    for (int cc = 0; cc < numColCluster; cc++){      if (colCS[cc] > 0){        tempDistance = colDistance(c, cc); 	updateVariable(minDistance, minCL, tempDistance, cc);      }    }    if (minCL != tempColCL)      colClusterChange++;    colCL[c] = minCL;  }  if (colAC != NULL){    for (int cc = 0; cc < numColCluster; cc++)      delete [] colAC[cc];    delete [] colAC;    colAC = NULL;  }  checkDumpLevel4NumOfChange("col(s)", colClusterChange);}void MssrIIcc::reassignCC(bool *isReversed){  int colClusterChange = 0;  int tempColCL, minCL;  double tempDistance, minDistance;  if (colAC == NULL){    colAC = new double*[numColCluster];    for (int cc = 0; cc < numColCluster; cc++)      colAC[cc] = new double[numRow];  }  computeRowCentroid(isReversed);	// rowCentroid, in R^(numRowCluster * numCol)  normalizeRowCentroid();  computeColCentroid(isReversed);	// colCentroid, in R^(numRow * numColCluster)  normalizeColCentroid();  computeColAC();			// colAC = nA^C = nAC - nRR'AC, in R^(numRow * numColCluster)  computeQuality4ColAC();		// colQuality4Compressed[c] = sum_i(nA^C_ic)^2 = sum_i(n_c^(-1/2) * A^C_ic)^2  for (int c = 0; c < numCol; c++){    tempColCL = colCL[c];    minCL = tempColCL;    computeColAP(c, isReversed);	// colAP_j = (A - RR'A)_j, in R^(1*numRow)    minDistance = MY_DBL_MAX;    for (int cc = 0; cc < numColCluster; cc++){      if (colCS[cc] > 0){        tempDistance = colDistance(c, cc); 	updateVariable(minDistance, minCL, tempDistance, cc);      }    }    if (minCL != tempColCL)      colClusterChange++;    colCL[c] = minCL;  }  if (colAC != NULL){    for (int cc = 0; cc < numColCluster; cc++)      delete [] colAC[cc];    delete [] colAC;    colAC = NULL;  }  checkDumpLevel4NumOfChange("col(s)", colClusterChange);}void MssrIIcc::reassignCC4Variation(bool *isReversed){  int colClusterChange = 0;  int tempColCL, minCL;  double tempDistance, minDistance;  if (colAC == NULL){    colAC = new double*[numColCluster];    for (int cc = 0; cc < numColCluster; cc++)      colAC[cc] = new double[numRow];  }//  computeRowCentroid(isReversed);	// rowCentroid, in R^(numRowCluster * numCol)//  normalizeRowCentroid();  computeColCentroid(isReversed);	// colCentroid, in R^(numRow * numColCluster)  normalizeColCentroid();  computeColAC();			// colAC = nA^C = nAC - nRR'AC, in R^(numRow * numColCluster)  computeQuality4ColAC();		// colQuality4Compressed[c] = sum_i(nA^C_ic)^2 = sum_i(n_c^(-1/2) * A^C_ic)^2  for (int c = 0; c < numCol; c++){    tempColCL = colCL[c];    minCL = tempColCL;    computeColAP(c, isReversed);	// colAP_j = (A - RR'A)_j, in R^(1*numRow)    minDistance = MY_DBL_MAX;    for (int cc = 0; cc < numColCluster; cc++){      if (colCS[cc] > 0){        tempDistance = colDistance(c, cc); 	updateVariable(minDistance, minCL, tempDistance, cc);      }    }    if (minCL != tempColCL)      colClusterChange++;    colCL[c] = minCL;  }  if (colAC != NULL){    for (int cc = 0; cc < numColCluster; cc++)      delete [] colAC[cc];    delete [] colAC;    colAC = NULL;  }  checkDumpLevel4NumOfChange("col(s)", colClusterChange);}void MssrIIcc::doBatchUpdate(){  checkDumpLevel4BatchUpdate("begin");  int numIteration = 0;  double oldObjValue;  computeRowClusterSize();  computeColClusterSize();  computeAcompressed();  isNormalizedCompressed = false;  normalizeCompressedMatrix();  computeRowCentroid();  normalizeRowCentroid();  computeColCentroid();  normalizeColCentroid();  do {    numIteration++;    myCRS->setSmoothingFactor(smoothingType, rowSmoothingFactor);    myCCS->setSmoothingFactor(smoothingType, colSmoothingFactor);    oldObjValue = objValue;        if (numRowCluster < numRow){      reassignRC();      computeRowClusterSize();      computeAcompressed();      isNormalizedCompressed = false;      normalizeCompressedMatrix();      computeRowCentroid();      normalizeRowCentroid();      computeObjectiveFunction4Normalized();      checkDumpLevel4BatchUpdate("row", numIteration);    }    if (numColCluster < numCol){      reassignCC();      computeColClusterSize();      computeAcompressed();      isNormalizedCompressed = false;      normalizeCompressedMatrix();      computeColCentroid();      normalizeColCentroid();      computeObjectiveFunction4Normalized();      checkDumpLevel4BatchUpdate("col", numIteration);    }    rowSmoothingFactor *= myCRS->getAnnealingFactor();    colSmoothingFactor *= myCCS->getAnnealingFactor();  } while ((oldObjValue - objValue) > (rowBatchUpdateThreshold * squaredFNormA));  checkDumpLevel4BatchUpdate("end");}void MssrIIcc::doBatchUpdate4VariationI(){  checkDumpLevel4BatchUpdate("begin");  int numIteration = 0;  double oldObjValue;  computeRowClusterSize();  computeColClusterSize();  computeAcompressed();  isNormalizedCompressed = false;  normalizeCompressedMatrix();  computeRowCentroid();  normalizeRowCentroid();  computeColCentroid();  normalizeColCentroid();  do {    numIteration++;    myCRS->setSmoothingFactor(smoothingType, rowSmoothingFactor);    myCCS->setSmoothingFactor(smoothingType, colSmoothingFactor);    oldObjValue = objValue;    reassignRC();    computeRowClusterSize();//    computeAcompressed();//    isNormalizedCompressed = false;//    normalizeCompressedMatrix();//    computeRowCentroid();//    normalizeRowCentroid();    computeObjectiveFunction4Normalized(Acompressed);    checkDumpLevel4BatchUpdate("row", numIteration);//------------    reassignCC4Variation();    computeColClusterSize();//    computeAcompressed();//    isNormalizedCompressed = false;//    normalizeCompressedMatrix();//    computeColCentroid();//    normalizeColCentroid();    computeObjectiveFunction4Normalized(Acompressed);    checkDumpLevel4BatchUpdate("col", numIteration);//------------    computeAcompressed();    isNormalizedCompressed = false;    normalizeCompressedMatrix();    computeRowCentroid();    normalizeRowCentroid();    computeColCentroid();    normalizeColCentroid();    computeObjectiveFunction4Normalized();    checkDumpLevel4BatchUpdate("both", numIteration);//------------    rowSmoothingFactor *= myCRS->getAnnealingFactor();    colSmoothingFactor *= myCCS->getAnnealingFactor();  } while ((oldObjValue - objValue) > (rowBatchUpdateThreshold * squaredFNormA));  checkDumpLevel4BatchUpdate("end");}void MssrIIcc::doBatchUpdate4VariationII(){  checkDumpLevel4BatchUpdate("begin");  int numIteration = 0;  double oldObjValue;  double tempRowSmoothingFactor = rowSmoothingFactor, tempColSmoothingFactor = colSmoothingFactor;    computeRowClusterSize();  computeColClusterSize();  computeAcompressed();  isNormalizedCompressed = false;  normalizeCompressedMatrix();  computeRowCentroid();  normalizeRowCentroid();  computeColCentroid();  normalizeColCentroid();  myCRS->setSmoothingFactor(smoothingType, tempRowSmoothingFactor);  myCCS->setSmoothingFactor(smoothingType, tempColSmoothingFactor);  do {    numIteration++;    myCRS->setSmoothingFactor(smoothingType, tempRowSmoothingFactor);    oldObjValue = objValue;    reassignRC();    computeRowClusterSize();    computeAcompressed();    isNormalizedCompressed = false;    normalizeCompressedMatrix();    computeRowCentroid();    normalizeRowCentroid();    computeObjectiveFunction4Normalized();    checkDumpLevel4BatchUpdate("row", numIteration);    tempRowSmoothingFactor *= myCRS->getAnnealingFactor();  } while ((oldObjValue - objValue) > (rowBatchUpdateThreshold * squaredFNormA));//------------  numIteration = 0;  tempRowSmoothingFactor = myCRS->getSmoothingFactor();  myCRS->setSmoothingFactor(smoothingType, tempRowSmoothingFactor);  do {    numIteration++;    myCCS->setSmoothingFactor(smoothingType, tempColSmoothingFactor);    oldObjValue = objValue;    reassignCC();    computeColClusterSize();    computeAcompressed();    isNormalizedCompressed = false;    normalizeCompressedMatrix();    computeColCentroid();    normalizeColCentroid();    computeObjectiveFunction4Normalized();    checkDumpLevel4BatchUpdate("col", numIteration);    tempColSmoothingFactor *= myCCS->getAnnealingFactor();  } while ((oldObjValue - objValue) > (colBatchUpdateThreshold * squaredFNormA));  colSmoothingFactor = tempColSmoothingFactor;  checkDumpLevel4BatchUpdate("end");

⌨️ 快捷键说明

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