mixle.evolve.space moduleΒΆ
A small typed search space: the categorical/integer/box gap-filler over the numeric BO backend.
mixle.doe optimizes over a continuous numeric box (a sequence of (low, high) bounds). Real
configuration search needs categorical and integer knobs too, and the evolutionary/bandit backends want
to sample and walk neighbors natively. Space is the encoding layer that gives both:
Space.to_bounds()β a continuous(low, high)box for the BO backend, with categoricals encoded as integer indices ([-0.5, k - 0.5]so a round lands on each level with equal width).Space.encode()/Space.decode()β the lossy round-trip between a config dict and the numeric vector the BO backend proposes (decode rounds integers / categorical indices, clips to range).Space.sample()/Space.neighbors()β native draws and local moves for the evolutionary/bandit backends that handle categoricals without going through the numeric box.
The space lives in evolve (not doe) on purpose: doe stays a pure numeric-box optimizer, and
the encoding policy that bridges categoricals into it is an evolve concern.
- class Space(dims)[source]
Bases:
objectA typed, named search space over
Real/Integer/Categoricaldims.Construct from a dict mapping each parameter name to its dimension:
space = Space({"mu": Real(-5, 5), "k": Integer(1, 4), "family": Categorical(["a", "b"])})
Dimension order is the insertion order of the dict;
encode()/decode()andto_bounds()all use that same fixed order so the numeric vector and the box align.- property ndim: int
- to_bounds()[source]
The continuous
(low, high)box for the BO backend (categoricals as integer indices).
- sample(rng)[source]
Draw a random config dict, each dimension sampled natively.
- Parameters:
rng (RandomState)
- Return type:
- encode(config)[source]
Encode a config dict into the numeric vector (in the fixed dimension order).
- decode(vector)[source]
Decode a numeric vector (BO proposal) back into a config dict (rounding / clipping).
- class Real(lo, hi)[source]
Bases:
objectA continuous dimension over
[lo, hi].- lo: float
- hi: float
- sample(rng)[source]
- Parameters:
rng (RandomState)
- Return type:
- class Integer(lo, hi)[source]
Bases:
objectAn integer dimension over the inclusive range
[lo, hi].- lo: int
- hi: int
- sample(rng)[source]
- Parameters:
rng (RandomState)
- Return type:
- class Categorical(choices)[source]
Bases:
objectAn unordered categorical dimension over a finite list of
choices.- sample(rng)[source]
- Parameters:
rng (RandomState)
- Return type: