def dim_comparator(val1, val2, name1, name2, dim_string, tolerance=0):
    """
    Get the string representation of the relations.

    Args:
        val1: dimensional value of object 1 (int).
        val2: dimensional value of object 2 (int).
        name1: name of object 1 (str).
        name2: name of object 2 (str).
        dim_string: dimension being compared (str).
        tolerance: level of tolerance for the comparator (int).

    Return:
        A string representing the correct comparative relation between the objects
        in the dimension.

    """
    diff = val1 - val2

    if abs(diff) <= tolerance:  # val1 == val2
        return 's_' + dim_string + '(' + str(name1) + ',' + str(name2) + ')'
    elif diff > tolerance:   # val1 > val2
        return 'm_' + dim_string + '(' + str(name1) + ',' + str(name2) + ')'
    elif diff < -tolerance:   # val1 < val2
        return 'l_' + dim_string + '(' + str(name1) + ',' + str(name2) + ')'