public static void main(final String[] args) throws IOException
	{
		// Initialize the cluster.
		Comm.init (args);
		
		// check arguments
		if (args.length != 3 && args.length != 4)
			usage();
		
		// Load data, section information, student information, relation file Name
		Resources.loadFromFile(args[0], args[1], args[2]);

		// Create schedule generator object.
		final Generator scheduleGenerator = Generator.create();

		// This variable is used to remember the number of schedules which have 
		// been iterated.
		long 		checkedSchedule = 0;
		
		// this variable is used to save the optimal schedule.
		Schedule	popularSchedule = null;
		
		// Remember the beginning time of the loop
		final long RunBegin_T = System.currentTimeMillis();

		// Iterate all possible schedule until there is no more possible schedule left
		while(scheduleGenerator.hasNext())
		{
			// Read the current Time, if the running time has exceed the 
			// time limit, then it will exit this loop, and mark the 
			// variable "overState" to show the reason it exit from the loop.
			final long CurTime_T = System.currentTimeMillis();
			if((CurTime_T - RunBegin_T) > TIME_LIMIT ){
				break;
			}
			
			// Increment the number of schedules which have been iterated.
			++checkedSchedule;
				
			// Get the current schedule which is created by schedule generator.
			final Schedule curSchedule = scheduleGenerator.next();
			
			// Submit this schedule to all the students, let them to vote.
			Ranker.rank(curSchedule);
			
			// If this is the first schedule, then save it to optimal schedule directly.
			if(popularSchedule == null){
				popularSchedule = curSchedule;
				continue;
			}
			// If this schedule's rank is lower than the current optimal schedule's,
			// then change the optimal schedule to this schedule.
			else if(popularSchedule.getRank() > curSchedule.getRank()){
				popularSchedule = curSchedule;
			}
		}
		
		// save result to file
		if(args.length == 4) {
			final File outputfile = new File(args[3]);
			outputfile.createNewFile();
			final PrintStream ps = new PrintStream(outputfile);
			ps.println(popularSchedule);
			ps.flush();
			ps.close();
		}
		
		// print out number of iterated schedules and stats
		final int[] counters = popularSchedule.getCounters();
		System.out.println("" + checkedSchedule + "\t" + popularSchedule.getRank() + "\t"
				+ counters[Schedule.SE_COUNTER] + "\t"
				+ counters[Schedule.CE_COUNTER] + "\t"
				+ counters[Schedule.ME_COUNTER] + "\t"
				+ counters[Schedule.FE_COUNTER]);
	}