def energy_balance_rule(mod, p, h):
    """
    **Constraint Name**: DR_Energy_Balance_Constraint
    **Enforced Over**: DR_OPR_HRZS

    The sum of all shifted load up is equal to the sum of all shifted load
    down within an horizon, i.e. there are no energy losses or gains.
    """
    return sum(mod.DR_Shift_Up_MW[p, tmp]
               for tmp in mod.TMPS_BY_BLN_TYPE_HRZ[
                   mod.balancing_type_project[p], h]) \
        == sum(mod.DR_Shift_Down_MW[p, tmp]
               for tmp in mod.TMPS_BY_BLN_TYPE_HRZ[
                   mod.balancing_type_project[p], h])