E-SE0003 — Async comprehension in the decorator API

Error Type

Syntax Error

Phase

defining a problem with the decorator API

Python exception

SyntaxError (builtin)

Message

Async comprehensions are not allowed in the decorator API.

Possible fix: remove the `async` keyword.

Cause

Inside a decorated function, a comprehension passed to jijmodeling.sum, prod, min, max, set, genarray, gendict, or problem.Constraint contains an async for clause, for example jm.sum(x[i] async for i in N) or jm.genarray(c[i] * x[t, i] async for (t, i) in (T, N)). Model definitions are ordinary synchronous code, and JijModeling index sets are not asynchronous iterables, so async for has no meaning here. Any of the chained for clauses being async triggers this error, not just the first one.

Fix

Remove the async keyword and write plain for clauses:

problem += jm.sum(x[i] for i in N)