E-IG0107 — Invalid size range dict

Error Type

Instance Generation Error

Phase

configuring random instance generation (the default= / options= arguments of Problem.generate_random_dataset / Problem.generate_random_instance)

Python exception

TypeError (builtin)

Message

Cannot interpret the given dict as a size range ({reason}).

Possible fix: use a bounds dict of the form `{"start": {"Included": 0}, "end": {"Included": 10}}` with non-negative integer endpoints, or pass a `(lower, upper)` tuple (the upper bound is exclusive).

({reason} is the underlying parse error, e.g. missing field `end` or unknown variant `included` )

Cause

A dictionary was passed as the size entry of a random-generation hint, but it does not have the shape of a bounds dict; the parenthesized reason in the message pinpoints the first offending part. A bounds dict must contain both a "start" and an "end" key, and each of them must be a bound written as {"Included": n}, {"Excluded": n} (with a non-negative integer n), or the string "Unbounded". Typical mistakes are omitting one of the two keys, misspelling the bound tags (for example lowercase "included"), or using a negative or non-integer endpoint such as 4.5.

Fix

Write both keys with properly tagged bounds, or use one of the simpler equivalent forms:

import jijmodeling as jm

problem.generate_random_dataset(
    options={
        "a": {"size": {"start": {"Included": 2}, "end": {"Excluded": 8}}},
        # equivalently (the tuple's upper bound is exclusive):
        "b": {"size": jm.generation.size.closed_open(2, 8)},
        "c": {"size": (2, 8)},
    },
)

The helper functions in jm.generation.size (closed, open, closed_open, at_least, at_most, …) construct these dicts for you and are less error-prone than writing them by hand.