private void updateS() {

		int maxIndex = -1;
		int minIndex = -1;

		int minValue = S.getActualDuration();
		int minWait = S.getWaitDuration();
		int minDuration = Integer.MAX_VALUE;
		
		//find min value and minimum value grater then S
		for (int i = 0; i < Sn.length; i++) {

			if (Sn[i].getActualDuration() < minValue) {
				
				minIndex = i;
				minValue = Sn[i].getActualDuration();
			
			} else if (Sn[i].getActualDuration() == minValue && Sn[i].getWaitDuration() < minWait) {
				
				minIndex = i;
				minWait = Sn[i].getWaitDuration();
			
			} else if (Sn[i].getActualDuration() > S.getActualDuration() && Sn[i].getActualDuration() < minDuration) {
				
				maxIndex = i;
				minDuration = Sn[i].getActualDuration();
			}

		}

		//if min smaller then S, update S
		if (minIndex != -1) {

			S = new SAIndividual(Sn[minIndex].clone().getPersonWorkLists());
			S.calculateFitness();

		} else {

			if (maxIndex == -1) maxIndex = rand.nextInt(Sn.length);

			//if probability enough big to accept minimum solution grater then S
			double Δf = Math.abs(S.getActualDuration() - Sn[maxIndex].getActualDuration());

			double P = Math.exp(-Δf/T);

			if (rand.nextDouble() < P) {
				S = new SAIndividual(Sn[maxIndex].clone().getPersonWorkLists());
				S.calculateFitness();
			}
		}

	}