E-IG0102 — Invalid size range hint

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 a value of type `{type_name}` as a size range.

Possible fix: pass one of the following:
  - a non-negative integer
  - a `range` with step 1
  - a `(lower, upper)` tuple (either side may be `None`; the upper bound is exclusive)
  - `None`
  - a bounds dict

({type_name} is the Python type name of the rejected value)

Cause

The size entry of a random-generation hint was a value that cannot be understood as a range of collection sizes. Accepted forms are: a non-negative integer (a fixed size), a Python range with step 1, a (lower, upper) tuple whose elements are non-negative integers or None (the upper bound is exclusive; None means unbounded on that side), None (fall back to the default), a (start, end) pair of bound dicts, or a bounds dict of the form {"start": ..., "end": ...}. Anything else is rejected with this error — including negative integers and floats such as 4.0, since a size must be a non-negative whole number.

Fix

Pass the size in one of the accepted forms, converting floats to integers where needed:

import jijmodeling as jm

problem.generate_random_dataset(
    options={
        "a": {"size": 5},                                # fixed size 5
        "b": {"size": range(1, 6)},                      # sizes 1–5
        "c": {"size": (2, 8)},                           # sizes 2–7 (upper bound exclusive)
        "d": {"size": jm.generation.size.closed(2, 8)},  # sizes 2–8
    },
)