E-CE0018 — Fixed value outside the variable domain

Error Type

Compile Error

Phase

compiling the problem into an OMMX instance

Python exception

ValueError

Message

The fixed value `{value}` is assigned to `{name}[{...}]`, which is outside the {...} of decision variable `{name}`.

Possible fix: use a subscript within the variable's shape or declared keys.

The first {...} is the subscript that was given; the second describes the variable’s domain and reads shape `{shape}` for tensor variables and keys `{keys}` for dict-keyed variables.

Cause

When a compiler is created with fixed_variables (e.g. Compiler.from_problem(problem, instance_data, fixed_variables=...)), every subscript in the dict fixing an indexed variable must exist within that variable’s declared shape (0-based) or key set. The error is raised when a subscript does not — e.g. fixing x[5, 2] when x has shape (4, 4), or x[42, "X"] when (42, "X") is not among the variable’s declared keys.

Fix

Use only subscripts that exist within the variable’s shape (0-based) or declared keys:

# x = problem.BinaryVar("x", shape=(n, n)) with n = 4
# Incorrect: (5, 2) is outside shape (4, 4)
compiler = jm.Compiler.from_problem(problem, {"N": 4}, fixed_variables={"x": {(5, 2): 1.0}})
# Correct:
compiler = jm.Compiler.from_problem(problem, {"N": 4}, fixed_variables={"x": {(3, 2): 1.0}})

This error concerns the subscript only; a fixed value that violates the variable’s declared bounds is reported separately as E-CE0205. The other fixed_variables structure mismatches have their own codes: a single scalar assigned to an indexed variable is E-CE0020, and a subscripted value assigned to a scalar variable is E-CE0021.