E-TE0018 — Too many subscripts
Error Type |
|
|---|---|
Phase |
type checking the model |
Python exception |
|
Message
Too many subscripts: the array has {...} dimension(s) (shape `[{shape}]`), but {...} subscript(s) were given (types: `{subscript}`).
Possible fix: give the array at most one subscript per dimension.
Cause
The array was subscripted with more indices than it has dimensions, e.g. writing x[i, j] for a 1-dimensional variable x.
Giving fewer subscripts than dimensions is legal partial indexing and does not raise this error.
Fix
Use at most as many indices as the array’s number of dimensions, or declare the array with the intended shape:
problem = jm.Problem("example")
x = problem.BinaryVar("x", shape=(n,))
x[i] # OK
x[i, j] # error: only 1 dimension