Class: Legion::Extensions::Agentic::Attention::FeatureBinding::Helpers::Feature

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb

Constant Summary

Constants included from Constants

Constants::ATTENTION_BOOST, Constants::BINDING_ALPHA, Constants::BINDING_CONFIRMATION_THRESHOLD, Constants::BINDING_DECAY, Constants::BINDING_STATE_LABELS, Constants::BINDING_STRENGTH_FLOOR, Constants::DEFAULT_BINDING_STRENGTH, Constants::FEATURE_DIMENSIONS, Constants::FEATURE_SALIENCE_FLOOR, Constants::ILLUSORY_CONJUNCTION_THRESHOLD, Constants::MAX_BINDINGS, Constants::MAX_BINDING_HISTORY, Constants::MAX_FEATURES, Constants::MAX_OBJECTS, Constants::STRENGTH_LABELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, dimension:, value:, source: :perception, salience: 0.5) ⇒ Feature

Returns a new instance of Feature.



15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 15

def initialize(id:, dimension:, value:, source: :perception, salience: 0.5)
  @id          = id
  @dimension   = dimension
  @value       = value
  @source      = source
  @salience    = salience.to_f.clamp(0.0, 1.0)
  @detected_at = Time.now.utc
end

Instance Attribute Details

#detected_atObject (readonly)

Returns the value of attribute detected_at.



12
13
14
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 12

def detected_at
  @detected_at
end

#dimensionObject (readonly)

Returns the value of attribute dimension.



12
13
14
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 12

def dimension
  @dimension
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 12

def id
  @id
end

#salienceObject

Returns the value of attribute salience.



13
14
15
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 13

def salience
  @salience
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 12

def source
  @source
end

#valueObject (readonly)

Returns the value of attribute value.



12
13
14
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 12

def value
  @value
end

Instance Method Details

#decayObject



28
29
30
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 28

def decay
  @salience = [@salience - BINDING_DECAY, 0.0].max
end

#faded?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 32

def faded?
  @salience <= FEATURE_SALIENCE_FLOOR
end

#salient?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 24

def salient?
  @salience > FEATURE_SALIENCE_FLOOR
end

#to_hObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/legion/extensions/agentic/attention/feature_binding/helpers/feature.rb', line 36

def to_h
  {
    id:          @id,
    dimension:   @dimension,
    value:       @value,
    source:      @source,
    salience:    @salience.round(4),
    detected_at: @detected_at
  }
end