Constraints

Constraints define valid conditions on outputs of the objective function that must be satisfied during optimization.

Each entry in VOCS.constraints is a key–value pair where:

  • key — constraint name (string)

  • value — a shorthand or longhand definition.

Examples

Shorthand forms:

from gest_api.vocs import VOCS

# Value must be less than 1.0
vocs = VOCS(constraints={"c": ["LESS_THAN", 1.0]})

# Value must be greater than 0.0
vocs = VOCS(constraints={"c": ["GREATER_THAN", 0.0]})

# Value must stay within [0, 1]
vocs = VOCS(constraints={"c": ["BOUNDS", [0.0, 1.0]]})

Longhand form:

from gest_api.vocs import BoundsConstraint, VOCS

c_con = BoundsConstraint(range=[0.0, 1.0])
vocs = VOCS(constraints={"c": c_con})

Associated classes:

class gest_api.vocs.BaseConstraint(*, dtype=None)
Parameters:

dtype (str | Type | Tuple | None)

class gest_api.vocs.LessThanConstraint(*, dtype=None, value)
Parameters:
  • dtype (str | Type | Tuple | None)

  • value (float)

class gest_api.vocs.GreaterThanConstraint(*, dtype=None, value)
Parameters:
  • dtype (str | Type | Tuple | None)

  • value (float)

class gest_api.vocs.BoundsConstraint(*, dtype=None, range)
Parameters:
  • dtype (str | Type | Tuple | None)

  • range (Annotated[list[float], Len(min_length=2, max_length=2)])

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.