using JuMP
set = Symbol[]
m = Model()
@variable(m, x[i in set])
@objective(m, Min, sum(x; init=0))
In this case, optimization is not impossible; rather, an unexpected error occurs when the program executes at @objective.
ERROR: LoadError: MethodError: no method matching _rewrite_generic_generator(::Expr, ::Symbol, ::Symbol, ::Symbol)
The function `_rewrite_generic_generator` exists, but no method is defined for this combination of argument types.
Closest candidates are:
_rewrite_generic_generator(::Expr, ::Symbol, ::Expr, ::Any)
@ MutableArithmetics .julia\packages\MutableArithmetics\VMS0x\src\rewrite_generic.jl:295
_rewrite_generic_generator(::Expr, ::Symbol, ::Expr)
@ MutableArithmetics .julia\packages\MutableArithmetics\VMS0x\src\rewrite_generic.jl:295
Does anyone know how to resolve this?
> versioninfo()
Julia Version 1.12.1
Commit ba1e628ee4 (2025-10-17 13:02 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
The underlying issue is that most mathematicians consider sum of the empty set to be 0, but Julia is a bit more picky. In JuMP we have tried to override the behaviour so that you get 0, but we miss some edge cases
versioninfo()
Julia Version 1.12.1
Commit ba1e628ee4 (2025-10-17 13:02 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
This works!
Thank you for your kind help. Now I can bypass this bug using langestefan and your method and continue executing the code. Don’t worry.