def fitness(ref_matrix, guess_matrix):
    """Returns the value of the fitness function.
    
    The input is the reference matrix and the guess matrix. The reference matrix is assumed to be regularized (to contain no zero elements)"""
    
    f=1
    
    for i in range (len(ref_matrix)):
        for j in range (len(ref_matrix)):
            f=f*(ref_matrix[i,j]**guess_matrix[i,j])
            
    
    
    #Convertion from the product to an exponential of a sum is being used; transpose is needed to compute M_ij log(N_ij) and not M_ij log(N_ji)
    
#     return(np.exp(np.trace(np.transpose(guess_matrix) .dot (np.log(ref_matrix) ) ) ))
    return(f)