E-CE0100 — Array shape mismatch

Error Type

Compile Error

Phase

compiling the problem into an OMMX instance

Python exception

ValueError

Message

Array shape mismatch between `[{...}]` and `[{...}]`.

Both operands of an elementwise operation or comparison must have the same shape.

Cause

Two arrays that must have the same shape evaluated to different shapes once instance data was substituted — most commonly the two sides of a constraint such as x == a, where the decision variable is declared with one shape (e.g. shape=(5,)) but the placeholder data supplied to the compiler has another length (e.g. 3).

Fix

Make the shapes agree: declare the decision variable’s shape in terms of the placeholder (e.g. shape=(a.len_at(0),)), or fix the instance data so its shape matches the declaration. You can also use genarray() or gendict() syntax to construct an array / dictionary of specific shape.