Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java	(revision 18)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java	(revision 19)
@@ -67,6 +67,6 @@
 		private EM clusterer = null;
 
-		private HashMap<Integer, Classifier> cclassifier = new HashMap<Integer, Classifier>();
-		private HashMap<Integer, Instances> ctraindata = new HashMap<Integer, Instances>(); 
+		private HashMap<Integer, Classifier> cclassifier;
+		private HashMap<Integer, Instances> ctraindata; 
 		
 		
@@ -115,4 +115,6 @@
 				int cnum = clusterer.clusterInstance(clusterInstance);
 				
+				//Console.traceln(Level.INFO, String.format("instance is in cluster: " + cnum));
+						
 				// 2. classify testata instance to the classifier
 				ret = cclassifier.get(cnum).classifyInstance(classInstance);
@@ -141,4 +143,7 @@
 			// 3. cluster data
 			//Console.traceln(Level.INFO, String.format("starting clustering"));
+			
+			cclassifier = new HashMap<Integer, Classifier>();
+			ctraindata = new HashMap<Integer, Instances>();
 			
 			// use standard params for now
@@ -173,4 +178,7 @@
 			}
 			
+			// Debug output
+			//Console.traceln(Level.INFO, String.format("number of clusters: " + clusterer.numberOfClusters()));
+			
 			// train one classifier per cluster, we get the clusternumber from the traindata
 			Iterator<Integer> clusternumber = ctraindata.keySet().iterator();
@@ -180,5 +188,5 @@
 				cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber));
 				
-				//Console.traceln(Level.INFO, String.format("classifier in cluster "+cnumber));
+				//Console.traceln(Level.INFO, String.format("building classifier in cluster "+cnumber + " with " + ctraindata.get(cnumber).size() + " traindata instances"));
 			}
 		}
Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java	(revision 18)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java	(revision 19)
@@ -70,14 +70,14 @@
 		
 		/* classifier per cluster */
-		private HashMap<Integer, Classifier> cclassifier = new HashMap<Integer, Classifier>();
+		private HashMap<Integer, Classifier> cclassifier;
 		
 		/* instances per cluster */
-		private HashMap<Integer, Instances> ctraindata = new HashMap<Integer, Instances>(); 
+		private HashMap<Integer, Instances> ctraindata; 
 		
 		/* holds the instances and indices of the pivot objects of the Fastmap calculation in buildClassifier*/
-		private HashMap<Integer, Instance> cpivots = new HashMap<Integer, Instance>();
+		private HashMap<Integer, Instance> cpivots;
 		
 		/* holds the indices of the pivot objects for x,y and the dimension [x,y][dimension]*/
-		private int[][] cpivotindices = new int[2][2];
+		private int[][] cpivotindices;
 
 		/* holds the sizes of the cluster multiple "boxes" per cluster */
@@ -144,5 +144,4 @@
 				Fastmap FMAP = new Fastmap(2);
 				EuclideanDistance dist = new EuclideanDistance(traindata);
-				
 				
 				// we set our pivot indices [x=0,y=1][dimension]
@@ -234,5 +233,4 @@
 			    */
 				
-				// TODO: can we be in more cluster than one?
 				// now we iterate over all clusters (well, boxes of sizes per cluster really) and save the number of the 
 				// cluster in which we are
@@ -244,5 +242,5 @@
 					
 					// now iterate over the boxes of the cluster and hope we find one (cluster could have been removed)
-					// or we are too far away from any cluster
+					// or we are too far away from any cluster because of the fastmap calculation with the initial pivot objects
 					for ( int box=0; box < this.csize.get(cnumber).size(); box++ ) { 
 						Double[][] current = this.csize.get(cnumber).get(box);
@@ -256,9 +254,9 @@
 				
 				// we want to count how often we are really inside a cluster
-				if ( found_cnumber == -1 ) {
-					CNOTFOUND += 1;
-				}else {
-					CFOUND += 1;
-				}
+				//if ( found_cnumber == -1 ) {
+				//	CNOTFOUND += 1;
+				//}else {
+				//	CFOUND += 1;
+				//}
 
 				// now it can happen that we dont find a cluster because we deleted it previously (too few instances)
@@ -306,4 +304,8 @@
 			this.show_biggest = true;
 			
+			cclassifier = new HashMap<Integer, Classifier>();
+			ctraindata = new HashMap<Integer, Instances>();
+			cpivots = new HashMap<Integer, Instance>();
+			cpivotindices = new int[2][2];
 			
 			// 1. copy traindata
@@ -339,9 +341,11 @@
 			
 			double[][] X = FMAP.getX();
+			distmat = new double[0][0];
+			System.gc();
 			
 			// quadtree payload generation
 			ArrayList<QuadTreePayload<Instance>> qtp = new ArrayList<QuadTreePayload<Instance>>();
 		    
-			// die max und min brauchen wir für die größenangaben der sektoren
+			// we need these for the sizes of the quadrants
 			double[] big = {0,0};
 			double[] small = {9999999,99999999};
@@ -365,5 +369,5 @@
 		    }
 		    
-		    Console.traceln(Level.INFO, String.format("size for cluster ("+small[0]+","+small[1]+") - ("+big[0]+","+big[1]+")"));
+		    //Console.traceln(Level.INFO, String.format("size for cluster ("+small[0]+","+small[1]+") - ("+big[0]+","+big[1]+")"));
 		    
 		    // 5. generate quadtree
@@ -410,5 +414,5 @@
 			
 			// here we keep things we need later on
-			// QuadTree sizes for later use
+			// QuadTree sizes for later use (matching new instances)
 			this.csize = new HashMap<Integer, ArrayList<Double[][]>>(QuadTree.csize);
 		
@@ -436,4 +440,6 @@
 			Iterator<Integer> clusternumber = ctraindata.keySet().iterator();
 			//cclassifier.clear();
+			
+			//int traindata_count = 0;
 			while ( clusternumber.hasNext() ) {
 				cnumber = clusternumber.next();
@@ -441,8 +447,10 @@
 				cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber));
 				//Console.traceln(Level.INFO, String.format("classifier in cluster "+cnumber));
-				//Console.traceln(Level.INFO, String.format("" + ctraindata.get(cnumber).size() + " instances in cluster "+cnumber));
-			}
-			
-			//Console.traceln(Level.INFO, String.format("num clusters: "+cclassifier.size()));
+				//traindata_count += ctraindata.get(cnumber).size();
+				//Console.traceln(Level.INFO, String.format("building classifier in cluster "+cnumber +"  with "+ ctraindata.get(cnumber).size() +" traindata instances"));
+			}
+			
+			// add all traindata
+			//Console.traceln(Level.INFO, String.format("traindata in all clusters: " + traindata_count));
 		}
 	}
