Avoid CHP Binaries When Not Needed #556
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors how the CHP (Combined Heat and Power) binary variable (
binCHPIsOnInTS) is created and used in the constraints, making its creation conditional on whether it is actually needed. It also adds a comprehensive test suite to ensure the binary variable is only created when required. The changes improve model efficiency and maintainability by avoiding unnecessary integer variables when possible.Conditional creation of CHP binary variable and refactoring of constraints:
binCHPIsOnInTSbinary variable is needed has been centralized inadd_chp_constraints, based on whether certain intercepts or parameters are non-zero (fuel burn intercept, thermal production intercept, minimum turn down fraction, or hourly O&M cost). The binary variable and related constraints are only added if necessary, which can significantly speed up solves for compatible scenarios. [1] [2]add_chp_fuel_burn_constraints,add_chp_thermal_production_constraints, andadd_chp_supplementary_firing_constraints) have been refactored to accept precomputed slope and intercept values and abinary_createdflag, instead of recalculating or assuming the binary variable always exists. This ensures constraints are only as complex as needed. [1] [2] [3]Testing improvements:
test/test_avoid_chp_binary.jl, has been added with multiple test cases to verify that the binary variable is created only when required (i.e., when intercepts or certain parameters are non-zero) and not otherwise. Each test manipulates scenario parameters and checks the model structure and solution.