E-IG0000 — Random generation for an empty RangeNat type

Error Type

Instance Generation Error

Phase

generating random instance data

Python exception

jijmodeling.ModelingError

Message

Cannot generate a random value of type `RangeNat<0>`: this type contains no values.

Possible fix: make sure that the expression {...}specifying the upper bound is a nonzero natural number.

The {...} slot shows the upper-bound expression when its source text is available — the fix line then reads Possible fix: make sure that the expression `{expr}` specifying the upper bound is a nonzero natural number. — and is simply omitted otherwise.

Cause

Random instance generation was asked to produce a value of type RangeNat<0>: the expression giving the range’s upper bound evaluated to 0, so the type contains no values at all.

Fix

Make the upper-bound expression evaluate to at least 1. The upper bound is the value of the placeholder’s dtype expression, so check both the expression itself and the values generated for the placeholders it references via the options argument of Problem.generate_random_dataset. For example, with problem.Placeholder("indices", dtype=M, shape=(3,)), make sure M cannot be generated as 0:

problem.generate_random_dataset(
    options={"M": {"value": range(1, 10)}},
)

If the expression is identically zero (for example dtype=M * 0), no generation option can fix it — rewrite the dtype expression instead. When the expression involves array lengths (such as a.len_at(0)), the corresponding size hints also feed into the bound.