E-MD0102 — Undefined category label

Error Type

Modeling Error

Phase

building the model

Python exception

jijmodeling.ModelingError

Message

Undefined category label `{name}`; available category labels: [{...}]

Cause

A CategoryLabel referenced by the model — for example as a placeholder’s dtype, in dict_keys, or in an expression such as label.count() — is not registered in this problem’s namespace. Because labels are passed as CategoryLabel objects returned by Problem.CategoryLabel(), which registers the label on that problem, this typically means the label object was created on a different Problem than the one being built or compiled.

Fix

Create the category label on the same Problem that uses it, and pass that object; the message lists the category labels that are currently defined.

L = problem.CategoryLabel("L")
chosen = problem.Natural("chosen", dtype=L, shape=(2,))