Neighborhood
Contents
Neighborhood
Neighborhood objets are Addons defining what a neighborhood is for a Variables via Variable Addon, or a Search space via Search space Addon.
from zellij.core import *
from zellij.core import MockModel
from zellij.utils.converters import *
lf = Loss()(MockModel())
sp = MixedSearchspace(ArrayVar(
IntVar("a",-5,5, neighborhood=IntMinmax(2)),
FloatVar("b",-5,5, neighborhood=FloatInterval(1.5)),
CatVar("b",['f1','f2','f3'], neighborhood=CatInterval()),
neighborhood=ArrayInterval()),
lf,
neighborhood=Intervals())
point = sp.random_point(1)
print(point)
neighbors = sp.to_continuous.convert([[-5,-5],[0,0],point,[5,5]])
print(float_points)
int_points = sp.to_continuous.reverse(float_points)
print(int_points)
Intervals
Intervals Neighborhood are based on drawing a random value between
.
- class Intervals(search_space=None, neighborhood=None)[source]
Bases:
zellij.core.addons.NeighborhoodSearch space Addon, used to determine the neighbor of a given point. All Variables of the Search space must have the neighbor addon implemented.
- Parameters
variable (Search space, default=None) – Targeted Search space.
neighborhood (list, default=None) – If a list of the shape of the values from the Search space. Modify the neighborhood attribute of all Variable Addon of type VarNeighborhood, for each Variables.
- neighborhood
- property neighborhood
- property target
- class ArrayInterval(variable=None, neighborhood=None)[source]
Bases:
zellij.core.addons.VarNeighborhoodSearch space Addon, used to determine the neighbor of an ArrayVar. neighbor kwarg must be implemented for all Variables of the ArrayVar.
- Parameters
variable (ArrayVar, default=None) – Targeted Variables.
neighborhood (list, default=None) – Not yet implemented
- neighborhood
- property neighborhood
- property target
- class FloatInterval(neighborhood, variable=None)[source]
Bases:
zellij.core.addons.VarNeighborhoodVariable Addon, used to determine the neighbor of a FloatVar. Draw a random point in
.- Parameters
variable (FloatVar, default=None) – Targeted Variables.
neighborhood (float, default=None) –

- neighborhood
- property neighborhood
- property target
- class IntInterval(neighborhood, variable=None)[source]
Bases:
zellij.core.addons.VarNeighborhoodVariable Addon, used to determine the neighbor of an IntVar. Draw a random point in
.- Parameters
variable (IntVar, default=None) – Targeted Variables.
neighborhood (int, default=None) –

- neighborhood
- property neighborhood
- property target
- class CatInterval(variable=None, neighborhood=None)[source]
Bases:
zellij.core.addons.VarNeighborhoodVariable Addon, used to determine the neighbor of a CatVar. Draw a random feature in CatVar.
- Parameters
variable (FlaotVar, default=None) – Targeted Variables.
neighborhood (int, default=None) – Undefined, for CatVar it draws a random feature.
- neighborhood
- property neighborhood
- property target
- class ConstantInterval(variable=None, neighborhood=None)[source]
Bases:
zellij.core.addons.VarNeighborhoodVariable Addon, used to determine the neighbor of a Constant. Do nothing. Return the constant.
- Parameters
variable (Constant, default=None) – Targeted Variables.
neighborhood (int, default=None) – Not implemented.
- neighborhood
- property neighborhood
- property target