Variables
Variables define the tunable inputs for the optimization problem.
Each entry in VOCS.variables is a key–value pair where:
key — variable name (string)
value — a variable definition, which may be shorthand or a full object.
Examples
Shorthand forms:
from gest_api.vocs import VOCS
# Continuous variable with bounds
vocs = VOCS(variables={"x": [0.0, 1.0]})
# Discrete variable with allowed values (numeric)
vocs = VOCS(variables={"x": {0, 1, 2}})
# Discrete variable with allowed values (strings)
vocs = VOCS(variables={"path": {"/usr", "/home", "/bin"}})
# Explicit type form
vocs = VOCS(variables={"x": {"type": "ContinuousVariable", "domain": [0.0, 1.0]}})
Longhand form:
from gest_api.vocs import ContinuousVariable, VOCS
x_var = ContinuousVariable(domain=[0.0, 1.0], dtype=float, default_value=0.5)
vocs = VOCS(variables={"x": x_var})
Associated classes:
- class gest_api.vocs.BaseVariable(*, dtype=None, default_value=None)
- Parameters:
dtype (str | Type | Tuple | None)
default_value (float | None)
- class gest_api.vocs.ContinuousVariable(*, dtype=None, default_value=None, domain)
- Parameters:
dtype (str | Type | Tuple | None)
default_value (float | None)
domain (Annotated[list[float], Len(min_length=2, max_length=2)])
- class gest_api.vocs.DiscreteVariable(*, dtype=None, default_value=None, values)
- Parameters:
dtype (str | Type | Tuple | None)
default_value (float | None)
values (Annotated[set[Any], Len(min_length=1, max_length=None)])
Note
The dtype (data type) field for any parameter can be set according to https://numpy.org/doc/stable/reference/arrays.dtypes.html. The type specified must be supported by the generator.
By default, the dtype value is None, which means the variable is a scalar
with a type determined by the generator.