SpineOpt.jl icon indicating copy to clipboard operation
SpineOpt.jl copied to clipboard

Unit flow upper bounds are not correctly calculated when using replacement expressions

Open nhniina opened this issue 6 months ago • 2 comments

Replacement expressions seem to lead to a too small unit flow upper bound, and potentially an infeasible model. It seems that parameters fix_ratio_in_out_unit_flow, fix_units_on_coefficient_in_out and unit_start_flow are not all correctly considered in the upper bounds. In my test, only fix_ratio_in_out_unit_flow has an effect on the upper bound.

Running SpineOpt with this input data JSON should reproduce the bug.

The input data sets fix_ratio_in_out_unit_flow = 1.66, fix_units_on_coefficient_in_out = 6.27 and unit_start_flow = 1000.0. The capacity of to_node = 100.0 and number_of_units = 1.0.

One would expect to see the following result for the upper bound of from_node unit_flow: 1000 + 6.27 + 1.66*100 = 1172.27. Instead, I get an upper bound of 166.

The model works as expected when using unit_incremental_heat_rate and unit_idle_heat_rate instead (scenario heatrate instead of Base). The model also works as expected when disabling replacement expressions in functions constraint_ratio_unit_flow_indices(m::Model, ratio) and add_variable_unit_flow!(m::Model). (In both of the cases that work, no upper bound for from_node unit_flow is created, only for to_node unit_flow.)

These are the resulting LP files:

  • Base_w_replacement_expr: Infeasible model with wrong upper bounds
  • heatrate: Feasible model, using heat rates instead of fix ratios
  • Base_wo_replacement_expr: Feasible model, disabling replacements expressions in SpineOpt functions

SpineOpt version: 76bd7266bb85adbf782e9652393fdf863d523e57

nhniina avatar Aug 09 '24 08:08 nhniina