def get_assign_default_value_rule(variable_name: str, default_value_parameter_name: str):
    """
    Returns a rule that sets a default value for a variable.

    @param variable_name: The name of the variable whose default should be set (as a string)
    @param default_value_parameter_name: The name of the parameter that stores the default values (as a string)
    @returns A rule that can be passed to a BuildAction(..., rule=<>) object.

    Example:

    mod.BuildGen_assign_default_value = BuildAction(
        mod.PREDETERMINED_GEN_BLD_YRS,
        rule=rule_assign_default_value("BuildGen", "gen_predetermined_cap")
    )

    The code above will iterate over BuildGen for all the elements in
    PREDETERMINED_GEN_BLD_YRS and will set BuildGen's default value
    to the respective value in gen_predetermined_cap.
    """

    def rule(m, *args):
        """
        The rule that is returned by the parent function.
        This inner function is called by pyomo when pyomo runs the rule.
        """
        # First retrieve the variable we want to set a default value for
        variable_to_set = getattr(m, variable_name)
        # Then retrieve the default value
        default_value = getattr(m, default_value_parameter_name)[args]

        # If the variable has the attribute, then we need to make two changes.
        if hasattr(variable_to_set, "scaled_var_name"):
            # First the default needs to be set on the _ScaledVariable not
            # the unscaled expression.
            variable_to_set = getattr(m, variable_to_set.scaled_var_name)
            # Second the default value needs to be scaled accordingly.
            default_value *= variable_to_set.scaling_factor

        # Set the variable to the default value
        variable_to_set[args] = default_value

    return rule