def _constraint_lb_and_ub_to_gurobi_sense_rhs_and_range_value(lb, ub):
    """Helper function used by Constraint and Model"""
    if lb is None and ub is None:
        raise Exception('Free constraint ...')
    elif lb is None:
        sense = '<'
        rhs = float(ub)
        range_value = 0.0
    elif ub is None:
        sense = '>'
        rhs = float(lb)
        range_value = 0.0
    elif lb == ub:
        sense = '='
        rhs = float(lb)
        range_value = 0.0
    elif lb > ub:
        raise ValueError('Lower bound is larger than upper bound.')
    else:
        sense = '='
        rhs = float(lb)
        range_value = float(ub - lb)
    return sense, rhs, range_value
