E-CE0021 — Subscripted fixed value for a scalar variable

Error Type

Compile Error

Phase

compiling the problem into an OMMX instance

Python exception

ValueError

Message

The fixed value `{value}` is assigned to `{name}[{...}]`, but `{name}` is a scalar decision variable.

Possible fix: assign it to `{name}` directly.

Cause

When a compiler is created with fixed_variables (e.g. Compiler.from_problem(problem, instance_data, fixed_variables=...)), each entry must match the indexing structure of the decision variable it fixes: a scalar variable takes a single scalar value, not a dict. The error is raised when a subscripted value (e.g. {"x": {(0,): 1.0}}) is assigned to a scalar variable (e.g. problem.BinaryVar("x")).

Fix

Drop the subscript and assign the value directly:

# x = problem.BinaryVar("x")
# Incorrect:
compiler = jm.Compiler.from_problem(problem, {}, fixed_variables={"x": {(0,): 1.0}})
# Correct:
compiler = jm.Compiler.from_problem(problem, {}, fixed_variables={"x": 1.0})