E-TE0017 — Value is not subscriptable
Error Type |
|
|---|---|
Phase |
type checking the model |
Python exception |
|
Message
An expression of type `{type_}` cannot be subscripted.
Only tensors, jagged arrays, tuples, and dicts support subscripts.
Cause
You subscripted a value that has no elements, such as a scalar placeholder, a scalar decision variable, or a boolean.
problem = jm.Problem("example")
x = problem.BinaryVar("x") # scalar, ndim=0
x[0] # error: not subscriptable
Fix
Only tensors (including jagged arrays), tuples, and dicts support subscripts. Declare the variable or placeholder with a shape (ndim >= 1) if you intend to index it, or remove the subscript.