cognition.decision.state

Re-usable state components

Classes

SelfReinitState

State that internally handles reinitialization.

SelfElaborationState

State that self-serves elaboration.

PTEState

Container for state that...

PEState

Convenience special case of PTEState

Module Contents

class cognition.decision.state.SelfReinitState

State that internally handles reinitialization.

Supply a subclass instance to a decision process as a state_initializer and the result will be internal control about dp reinit.

_reinit()

Override to implement custom reinit logic

Return type:

None

__call__()
Return type:

Self

class cognition.decision.state.SelfElaborationState

Bases: SelfReinitState

State that self-serves elaboration.

A decision process that uses an instance’s elaborator property will provide it an opportunity for elaboration (during the phase), whose read-only results are then accessible via a protected property (that can then be exposed via state-designer preference).

ELABORATOR_NAME: str = 'self_elab'

Name of the resulting elaborator

property elaborator: cognition.decision.core.Elaborator[Self]
Returns:

fixed elaborator for this instance

Return type:

cognition.decision.core.Elaborator[Self]

_elaborate(io)

Override to implement custom elaboration logic

Parameters:

io (cognition.decision.core.IOContainer) – access to current IO

Returns:

name=value set for current elaboration

Return type:

collections.abc.Mapping[str, Any]

class cognition.decision.state.PTEState[P, T](p_init_value, t_init)

Bases: SelfElaborationState

Container for state that…

  • is (P)ersistant across dp reinitialization;

  • is (T)ransient, and so is reset each dp reinit; and

  • is (E)laborated each cycle based upon P/T state + IO via a custom implementation of _elaborate

Parameters:
property p: P
Returns:

persistent state

Return type:

P

property t: T
Returns:

transient state

Return type:

T

property e: cognition.util.misc.AttrReferral
Returns:

elaborated state

Return type:

cognition.util.misc.AttrReferral

__str__()
Return type:

str

class cognition.decision.state.PEState[P](p_init_value)

Bases: PTEState[P, None]

Convenience special case of PTEState whose transient state is None

Parameters:

p_init_value (P) – initial value of persistent state