Penalty functions based upon a general class of restricted dissimilarity functions