public void calculate(){
		
		int i = 0;
		Random rand = new Random();
		permutation_.genPermutation();
		Permutation permutationPrim = permutation_.clone();

		double difference = 0.0;
		while(i++ < numberOfIteration_){
			permutationPrim.switchValues();

			difference = MeanValueCalculator.calculate(matrix_, permutationPrim) - MeanValueCalculator.calculate(matrix_, permutation_);

			if(difference < 0){
				permutation_ = permutationPrim.clone();
				bestResult_ = MeanValueCalculator.calculate(matrix_, permutation_);
				notifyall();
			}
			else{
				double x = rand.nextDouble();
				
				if(x < Math.exp(-(difference/temperature_))){
					

					permutation_ = permutationPrim.clone();
					bestResult_ = MeanValueCalculator.calculate(matrix_, permutation_);
					notifyall();
				}
			}
			temperature_ = n_*temperature_;
		}
		try {
			PrintWriter printWriter = new PrintWriter(new File("wyniksimulatedannealing.txt"));
			
			String string = new String();
			for(int z = 0; z < 16; z++){
				for(int j = 0; j < permutation_.getPermutation().get(z).size(); j++)
				string += "{" + z + " " + permutation_.getPermutation().get(z).get(j) + "} ";
			}
			string += " " + bestResult_;
			printWriter.print(string);
			printWriter.close();
		} catch (IOException e) {
		}
	}