bool EFILE::add(Particle &_particle,int _whichcluster){
  //assert (_particle.fx.size() == nobjectives);
  bool _flag=true;

  std::vector<bool> erase;
  std::vector<int> _delparticles;

  addAll(_particle);

  for(int _i(0);_i<nsolutions;_i++){
    int _tmp=domine(solutions[_i],_particle);

    if(_tmp==1||_tmp==0) {
      _flag=false;
    }
    if(_tmp==-1){
      _delparticles.push_back(_i);
      erase.push_back(true);
    }
    else erase.push_back(false);
  }
  if(_delparticles.size()>0)
  updateClusters(_delparticles);

   std::vector<bool>::iterator _iterator=erase.begin();
   std::vector<Particle>::iterator _iterator2=solutions.begin();
   int _delindicator(0);
   for(_iterator=erase.begin(); _iterator != erase.end();++_iterator,_delindicator) {
     if(*_iterator==true){
       solutions.erase(_iterator2);
       nsolutions--;
     }
     else
       _iterator2++;
   }
  if(_flag==true){
    if(nsolutions>=maxsolutions+maxsolutions/10){
      update();
      add(_particle);
      return _flag;
    }
    else{
      if(_whichcluster!=-1)add2Cluster(_whichcluster);
      solutions.push_back(_particle);
      nsolutions++;
    }
  }

  if(nsolutions<=maxsolutions-maxsolutions/10){
    hasentered=false;
    firsttime=true;
  }
   // update();

  return _flag;

}
bool KlustersView::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: updatedDimensions((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 1: singleColorUpdated((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 2: clusterRemovedFromView((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 3: clusterAddedToView((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 4: newClusterAddedToView((QValueList<int>&)*((QValueList<int>*)static_QUType_ptr.get(_o+1)),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 5: newClusterAddedToView((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 6: spikesRemovedFromClusters((QValueList<int>&)*((QValueList<int>*)static_QUType_ptr.get(_o+1)),(bool)static_QUType_bool.get(_o+2)); break;
    case 7: modeToSet((BaseFrame::Mode)(*((BaseFrame::Mode*)static_QUType_ptr.get(_o+1)))); break;
    case 8: spikesAddedToCluster((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 9: updateContents(); break;
    case 10: emptySelection(); break;
    case 11: modifiedClusters((QValueList<int>&)*((QValueList<int>*)static_QUType_ptr.get(_o+1)),(bool)static_QUType_bool.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 12: modifiedClustersUndo((QValueList<int>&)*((QValueList<int>*)static_QUType_ptr.get(_o+1)),(bool)static_QUType_bool.get(_o+2)); break;
    case 13: updatedTimeFrame((long)(*((long*)static_QUType_ptr.get(_o+1))),(long)(*((long*)static_QUType_ptr.get(_o+2)))); break;
    case 14: sampleMode(); break;
    case 15: timeFrameMode(); break;
    case 16: meanPresentation(); break;
    case 17: allWaveformsPresentation(); break;
    case 18: overLayPresentation(); break;
    case 19: sideBySidePresentation(); break;
    case 20: increaseAmplitude(); break;
    case 21: decreaseAmplitude(); break;
    case 22: updateDisplayNbSpikes((long)(*((long*)static_QUType_ptr.get(_o+1)))); break;
    case 23: increaseAmplitudeofCorrelograms(); break;
    case 24: decreaseAmplitudeofCorrelograms(); break;
    case 25: noScale(); break;
    case 26: maxScale(); break;
    case 27: shoulderScale(); break;
    case 28: updatedBinSizeAndTimeFrame((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 29: setShoulderLine((bool)static_QUType_bool.get(_o+1)); break;
    case 30: updateDrawing(); break;
    case 31: changeGain((int)static_QUType_int.get(_o+1)); break;
    case 32: changeTimeInterval((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 33: changeChannelPositions((QValueList<int>&)*((QValueList<int>*)static_QUType_ptr.get(_o+1))); break;
    case 34: computeProbabilities(); break;
    case 35: changeBackgroundColor((QColor)(*((QColor*)static_QUType_ptr.get(_o+1)))); break;
    case 36: clustersRenumbered((bool)static_QUType_bool.get(_o+1)); break;
    case 37: updateClusters((QString)static_QUType_QString.get(_o+1),(QValueList<int>&)*((QValueList<int>*)static_QUType_ptr.get(_o+2)),(ItemColors*)static_QUType_ptr.get(_o+3),(bool)static_QUType_bool.get(_o+4)); break;
    case 38: increaseAllAmplitude(); break;
    case 39: decreaseAllAmplitude(); break;
    case 40: showLabels((bool)static_QUType_bool.get(_o+1)); break;
    case 41: nextCluster(); break;
    case 42: previousCluster(); break;
    default:
	return KDockArea::qt_emit(_id,_o);
    }
    return TRUE;
}
Example #3
0
vector<vector<DotNode*> > GraphKMeans::cluster(ConnectedDotGraph& g, int K)
{
	assert(K >= 1);

	VVN res;
	double bestValue = -1;

	for (int attempt = 0; attempt < 10; attempt++)
	{
		vector<DotNode*> centers = chooseCenters(g, K);

		ClusteringInfo clusterInfo = groupPoints(centers, g);
		updateClusters(clusterInfo, g);

		double value = clusterInfo.getModularity();
		if (bestValue == -1 || bestValue < value)
		{
			bestValue = value;
			res = clusterInfo.getGroups();
		}
	}

	return res;
}
Example #4
0
// Constructor parses the image
ImgTexture::ImgTexture(const ofImage& inImage, const ofPixels& inClusteredImage, int inAmountOfClusters, std::vector<BYTE> inClusterColors)
{
	// Make sure amount of clusets is same size as amount of colors
	assert(inAmountOfClusters == inClusterColors.size());

	// Now set the data
	mOriginalPixels = inImage;
	mOriginalClusteredImage = inClusteredImage;
	mClusterAmount = inAmountOfClusters;

	// Set the cluster colors
	mClusterColors = inClusterColors;
	mClusterColors.resize(inAmountOfClusters);

	// Initializes the cluster sets
	initClusterSets();

	// Update our images
	updateImage(ofGetWidth(), ofGetHeight());
	updateClusters(ofGetWidth(), ofGetHeight());

	// Unbind the clustered image
	mResizedClusteredImage.unbind();
}
Example #5
0
ImgCluster::ImgCluster(ofImage inImage)
{
	mOriginalImage = inImage;
	updateClusters(ofGetWidth(), ofGetHeight());
}