E-TE0609 — Non-callable passed where a callable is expected
Error Type |
|
|---|---|
Phase |
building a model from Python |
Python exception |
|
Message
Expected a callable object, but got `{type_name}`.
Possible fix: pass a function or a lambda, such as `lambda i: x[i]`.
({type_name} is the Python type of the rejected value)
Cause
A JijModeling API that takes a function received a value that is not callable.
The positions checked are the function argument of jm.map, jm.filter, jm.flat_map, jm.genarray, and jm.gendict, and of the method forms .map(...), .filter(...), and .flat_map(...) on expressions, placeholders, decision variables, and category labels.
A common trigger is swapping the argument order of the free functions: the callable comes first, so jm.map(N, lambda i: x[i]) raises this error (with Placeholder as the reported type) because N sits in the function position.
Fix
Pass a function or lambda taking one argument per index, and put it in the function position:
jm.map(lambda i: W[i] * x[i], N) # callable first, index set second
N.map(lambda i: W[i] * x[i]) # or use the method form
jm.genarray(lambda t, i: C[i] * x[t, i], (T, N))
If you already have the element expression rather than a function, wrap it in a lambda, for example lambda i: expr.