Skip to content

[Bug]: MethodError in thermal_no_commit_operational_reserves! when UCommit=0 and OperationalReserves=1 #906

Description

@ibanmd

Bug description

When running GenX with LP relaxation (UCommit=0) and operational reserves enabled (OperationalReserves=1), the model crashes with a MethodError in extract_time_series_to_expression. The root cause is a type inference issue in load_resources_data.jl.

At line 1209 of load_resources_data.jl, inputs["THERM_COMMIT"] is assigned [] (an empty Vector{Any}). This propagates to inputs["COMMIT"]. Later, in thermal_no_commit.jl line 153, the call setdiff(inputs["THERM_ALL"], inputs["COMMIT"]) produces a Vector{Any} instead of Vector{Int64}, which doesn't match the method signature of extract_time_series_to_expression.

Link: https://github.com/GenXProject/GenX.jl/blob/main/src/load_inputs/load_resources_data.jl#L1209

Environment and Version

GenX version: v0.4.5
Julia version: 1.11.4
Solver: HiGHS

Relevant error messages

MethodError: no method matching extract_time_series_to_expression(...)

  Triggered in thermal_no_commit_operational_reserves! via the call chain:
  1. load_resources_data.jl:1209 — inputs["THERM_COMMIT"] = [] creates Vector{Any}
  2. This propagates to inputs["COMMIT"]
  3. thermal_no_commit.jl:153 — setdiff(inputs["THERM_ALL"], inputs["COMMIT"]) returns Vector{Any}
  4. extract_time_series_to_expression rejects Vector{Any}, expects Vector{Int64}

Additional context

  • The bug only manifests when both UCommit=0 and OperationalReserves=1. With UCommit=1 (full commitment), THERM_COMMIT is populated with Int64 values and the issue doesn't arise. With OperationalReserves=0, the faulty code path is never reached.
  • The fix is a one-character change ([] → Int[]) with no behavioral side effects — the vector is empty in this code path regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions