pg.geno.Space

Accessible via pg.geno.Space, pg.geno.space.

class Space(elements=[], index=None, *, location=, hints=None)[source]

Bases: pg.DNASpec

Represents a search space that consists of a list of decision points.

Example:

# Create a constant space.
space = pg.geno.Space([])

# Create a space with one categorical decision point
# and a float decision point
space = pg.geno.space([
    pg.geno.oneof([
        pg.geno.constant(),
        pg.geno.constant(),
   ]),
   pg.geno.floatv(0.0, 1.0)
])

See also: pg.geno.Space, pg.geno.constant.

Attributes:

decision_points

Returns all decision points in their declaration order.

is_categorical

Returns True if current node is a categorical choice.

is_constant

Returns whether this template is constant.

is_custom_decision_point

Returns True if current node is a custom decision point.

is_numerical

Returns True if current node is numerical decision.

is_space

Returns True if current node is a sub-space.

is_subchoice

Returns True if current node is a subchoice of a multi-choice.

space_size

Returns the size of the search space.

Methods:

format([compact, verbose, root_indent])

Format this object.

validate(dna)

Validate whether a DNA value conforms to this spec.

property decision_points: List[DecisionPoint][source]

Returns all decision points in their declaration order.

format(compact=True, verbose=True, root_indent=0, **kwargs)[source]

Format this object.

property is_categorical: bool[source]

Returns True if current node is a categorical choice.

property is_constant: bool[source]

Returns whether this template is constant.

A constant Space does not have any genetic encoders.

property is_custom_decision_point: bool[source]

Returns True if current node is a custom decision point.

property is_numerical: bool[source]

Returns True if current node is numerical decision.

property is_space: bool[source]

Returns True if current node is a sub-space.

property is_subchoice: bool[source]

Returns True if current node is a subchoice of a multi-choice.

property space_size: int[source]

Returns the size of the search space. Use -1 for infinity.

validate(dna)[source]

Validate whether a DNA value conforms to this spec.

Return type:

None