public double minct() {
		sortClass();
		calculateWeight();

		dmMinminCost = new double[iSite][iCPUMaxNum];
		dmMinminTime = new double[iSite][iCPUMaxNum];

		double[] daMinminTimeBySite = new double[iSite];
		boolean lastActivity;
		// find the current fastest site for the acitvities.
		while (getRestLength() > 0) {
			for (int k = 0; k < iClass; k++) {
				for (int i = 0; i < iaTask[k]; i++) {
					iMinClass = k;
					findMinCompleteCPU();
					if (iMinSite < 0) {
						System.out.println("FAILED to find a solution!!!");
						return -1;
					}

					iaQueuedTask[k]--;
					if (iaQueuedTask[k] == 0) {
						lastActivity = true;
					} else {
						lastActivity = false;
					}
					updateMin();
					registerStorage(lastActivity);// must do it after
													// updateMin
					iStage++;
				}
			}

			// k = Math.round(Math.round(Math.random()*(iClass+1))) % iClass;
			// if (iaCurrentLength[k]>0)
			// {
			// iMinClass = k;
			// findMinCompleteCPU();
			// //
			// System.out.println(k+":"+iMinSite+"="+dmPrediction[iMinClass][iMinSite]);
			// iaCurrentLength[k]--;
			// updateMin();
			// iStage++;
			//                    
			// }
		}

		updateStorage(Double.MAX_VALUE,-1);

		double sumTime = 0, sumCost = 0;
		int xMaxTime = 0, yMaxtime = 0;
		double tmpTime = -1;
		for (int i = 0; i < iSite; i++) {

			for (int j = 0; j < iaCPU[i]; j++) {
				daMinminTimeBySite[i] += dmMinminTime[i][j];
				// find cpu with the maximum execution time
				if (tmpTime < dmMinminTime[i][j]) {
					xMaxTime = i;
					yMaxtime = j;
					tmpTime = dmMinminTime[i][j];
				}

				sumTime += dmMinminTime[i][j];
				sumCost += dmMinminCost[i][j];
			}
		}
		// for (int i = 0; i < iClass; i++)
		// {
		// System.out.print(iStage + "Distribution[" + i + "]");
		// for (int j = 0; j < iSite; j++)
		// {
		// System.out.print(dmDistribution[i][j] + ", ");
		// }
		// System.out.println();
		// }
		System.out.println("MCT Fairness = " + calculateFairness());
		System.out.println("MCT Time     = " + sumTime);
		System.out.println("MCT Cost     = " + sumCost);
		System.out.println("MCT Makespan = " + tmpTime);
		System.out.println("MCT Stage    = " + iStage);

		dFinalMakespan = tmpTime;
		dCost = sumCost;
		dTime = sumTime;
		return sumTime;

	}