E-TE0608 — Invalid placeholder data type

Error Type

Type Error

Phase

declaring a placeholder

Python exception

TypeError (builtin)

Message

`{value}` of type `{type_name}` is not a valid placeholder data type.

Possible fix: use one of the following:
  - `jijmodeling.DataType`
  - a Python or NumPy scalar type such as `int` or `float`
  - a `CategoryLabel`
  - a tuple of these
  - an expression for a natural number

({value} is the offending argument as Python displays it, and {type_name} is its Python type)

Cause

The dtype argument of a placeholder declaration such as problem.Placeholder("a", dtype=...) was not one of the accepted forms. Accepted forms are:

  • a jijmodeling.DataType value such as jm.DataType.FLOAT,

  • one of the Python scalar types int, float, or bool,

  • a NumPy integer type such as numpy.int64 or numpy.uint32, or one of NumPy’s abstract numeric types such as numpy.integer, numpy.unsignedinteger, numpy.floating, or numpy.number (also as a numpy.dtype object wrapping such a type),

  • a tuple of accepted forms, written either as a literal tuple like (int, int) or as typing.Tuple[int, int],

  • a CategoryLabel,

  • an expression evaluating to a natural number (including a plain integer such as dtype=10), which restricts the placeholder’s values to the natural numbers below that bound.

A value that matches none of these forms — for example dtype=None or the unsupported type object str — raises this error.

Fix

Pass one of the accepted forms as dtype:

import jijmodeling as jm

problem = jm.Problem("example")
n = problem.Placeholder("n", dtype=jm.DataType.NATURAL)
cost = problem.Placeholder("cost", dtype=float, shape=(n,))
edges = problem.Placeholder("edges", dtype=(int, int), shape=(n,))
color = problem.Placeholder("color", dtype=n, shape=(n,))  # naturals below n

For floating-point data use Python’s float or NumPy’s abstract numpy.floating; the concrete NumPy floating types such as numpy.float64 are not recognized.