E-TE0600 — Value cannot be interpreted as an expression

Error Type

Type Error

Phase

building expressions from Python

Python exception

TypeError (builtin)

Message

Cannot interpret a value of type `{type_name}` as an expression.

Possible fix: pass one of the following:
  - a number
  - a placeholder
  - a decision variable
  - a category label
  - an expression
  - a tuple/list/dict of expressions
  - a callable building an expression

If you passed a container, make sure every element is itself an expression.

({type_name} is the Python type name of the rejected value)

Cause

A value was passed to a JijModeling API in a position where an expression is expected — for example an objective term, a constraint body, a subscript, a shape entry, or the operand of functions such as jm.sum — and it is not one of the accepted kinds. Accepted values are: expressions, plain numbers, booleans, and strings, placeholders, decision variables, named expressions, category labels, tuples/lists/dicts of such values, slices, and callables taking at least one argument. Anything else — for example None, a Python set, or an object from an unrelated library — is rejected with this error.

Fix

Replace the value with one of the accepted kinds listed in the message. In particular, if you are trying to embed raw problem data into the model, define a placeholder instead and supply the data when compiling:

# problem += jm.sum(my_data_object * x)   # raises E-TE0600
W = problem.Float("W", ndim=1)            # model the data as a placeholder
problem += jm.sum(W * x)
# ... and pass {"W": my_data} in the instance data when compiling

If you passed a callable and still see an error, note that it must take at least one argument (see E-TE0602).