// Solve a series of relaxed problems for maximum flexibility solution
void solveStaged(size_t addMutex = 2) {

	// super-hack! just count...
	bool debug = false;
	SETDEBUG("DiscreteConditional::COUNT", true);
	SETDEBUG("DiscreteConditional::DiscreteConditional", debug); // progress

	// make a vector with slot availability, initially all 1
	// Reads file to get count :-)
	vector<double> slotsAvailable(largeExample(0).nrTimeSlots(), 1.0);

	// now, find optimal value for each student, using relaxed mutex constraints
	for (size_t s = 0; s < NRSTUDENTS; s++) {
		// add all students first time, then drop last one second time, etc...
		Scheduler scheduler = largeExample(NRSTUDENTS - s);
		//scheduler.print(str(boost::format("Scheduler %d") % (NRSTUDENTS-s)));

		// only allow slots not yet taken
		scheduler.setSlotsAvailable(slotsAvailable);

		// BUILD THE GRAPH !
		scheduler.buildGraph(addMutex);

		// Do EXACT INFERENCE
		tic_(3,"eliminate");
		DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate();
		toc_(3,"eliminate");

		// find root node
		DiscreteConditional::shared_ptr root = *(chordal->rbegin());
		if (debug)
			root->print(""/*scheduler.studentName(s)*/);

		// solve root node only
		Scheduler::Values values;
		size_t bestSlot = root->solve(values);

		// get corresponding count
		DiscreteKey dkey = scheduler.studentKey(NRSTUDENTS - 1 - s);
		values[dkey.first] = bestSlot;
		size_t count = (*root)(values);

		// remove this slot from consideration
		slotsAvailable[bestSlot] = 0.0;
		cout << boost::format("%s = %d (%d), count = %d") % scheduler.studentName(NRSTUDENTS-1-s)
				% scheduler.slotName(bestSlot) % bestSlot % count << endl;
	}
	tictoc_print_();
}