public float cost(ArrayList<Pair> permutation, int[] container_classes, int[][] communication_matrix) {
        //initially consider all nodes to be powered up (then reduced it on encountering [-1,-1] 
        num_of_powered_nodes = permutation.size();
        num_of_collocated_devils = 0;
        num_of_collocated_comms = 0;

        //assumption : number of processes OR length of permutation is even
        //assumption : number of cores per processor is 2
        for (int i = 0; i < permutation.size(); i++) {
            if (permutation.get(i).first == -1 || permutation.get(i).second == -1) {
                if (permutation.get(i).first == -1 && permutation.get(i).second == -1)
                    num_of_powered_nodes--;
            } else {

                if (container_classes[permutation.get(i).first] == 1 && container_classes[permutation.get(i).first] == container_classes[permutation.get(i).second]) {
                    num_of_collocated_devils++;
                }
                //the communication matrix might not be symmetric.
                //Hence, we need different operators
                if (communication_matrix[permutation.get(i).first][permutation.get(i).second] == 1 || 
                		communication_matrix[permutation.get(i).second][permutation.get(i).first] == 1) {
                    num_of_collocated_comms++;
                }
            }
        }
        
        float weighted_sum = p*num_of_powered_nodes + d*num_of_collocated_devils - c*num_of_collocated_comms;
        return weighted_sum;
    }