Class: Legion::Extensions::Agentic::Integration::PhenomenalBinding::Helpers::BindingUnit
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Integration::PhenomenalBinding::Helpers::BindingUnit
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb
Constant Summary
Constants included from Constants
Constants::BINDING_BOOST, Constants::BINDING_DECAY, Constants::BINDING_TYPES, Constants::COHERENCE_LABELS, Constants::COHERENCE_THRESHOLD, Constants::DEFAULT_SALIENCE, Constants::MAX_BINDINGS, Constants::MAX_STREAMS, Constants::STREAM_TYPES
Instance Attribute Summary collapse
-
#attention_weight ⇒ Object
readonly
Returns the value of attribute attention_weight.
-
#binding_type ⇒ Object
readonly
Returns the value of attribute binding_type.
-
#coherence ⇒ Object
readonly
Returns the value of attribute coherence.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#stream_ids ⇒ Object
readonly
Returns the value of attribute stream_ids.
Instance Method Summary collapse
- #add_stream(stream_id:) ⇒ Object
- #coherence_label ⇒ Object
- #coherent? ⇒ Boolean
- #decay! ⇒ Object
-
#initialize(stream_ids:, binding_type:, coherence:, attention_weight: 0.5) ⇒ BindingUnit
constructor
A new instance of BindingUnit.
- #reinforce! ⇒ Object
- #remove_stream(stream_id:) ⇒ Object
- #stream_count ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(stream_ids:, binding_type:, coherence:, attention_weight: 0.5) ⇒ BindingUnit
Returns a new instance of BindingUnit.
16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 16 def initialize(stream_ids:, binding_type:, coherence:, attention_weight: 0.5) @id = ::SecureRandom.uuid @stream_ids = stream_ids.dup @binding_type = binding_type @coherence = coherence.clamp(0.0, 1.0) @attention_weight = attention_weight.clamp(0.0, 1.0) @created_at = Time.now.utc end |
Instance Attribute Details
#attention_weight ⇒ Object (readonly)
Returns the value of attribute attention_weight.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 14 def attention_weight @attention_weight end |
#binding_type ⇒ Object (readonly)
Returns the value of attribute binding_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 14 def binding_type @binding_type end |
#coherence ⇒ Object (readonly)
Returns the value of attribute coherence.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 14 def coherence @coherence end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 14 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 14 def id @id end |
#stream_ids ⇒ Object (readonly)
Returns the value of attribute stream_ids.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 14 def stream_ids @stream_ids end |
Instance Method Details
#add_stream(stream_id:) ⇒ Object
25 26 27 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 25 def add_stream(stream_id:) @stream_ids << stream_id unless @stream_ids.include?(stream_id) end |
#coherence_label ⇒ Object
45 46 47 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 45 def coherence_label COHERENCE_LABELS.find { |range, _| range.cover?(@coherence) }&.last || :unbound end |
#coherent? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 41 def coherent? @coherence >= COHERENCE_THRESHOLD end |
#decay! ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 37 def decay! @coherence = (@coherence - BINDING_DECAY).clamp(0.0, 1.0) end |
#reinforce! ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 33 def reinforce! @coherence = (@coherence + BINDING_BOOST).clamp(0.0, 1.0) end |
#remove_stream(stream_id:) ⇒ Object
29 30 31 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 29 def remove_stream(stream_id:) @stream_ids.delete(stream_id) end |
#stream_count ⇒ Object
49 50 51 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 49 def stream_count @stream_ids.size end |
#to_h ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb', line 53 def to_h { id: @id, stream_ids: @stream_ids.dup, binding_type: @binding_type, coherence: @coherence.round(10), attention_weight: @attention_weight.round(10), coherent: coherent?, coherence_label: coherence_label, stream_count: stream_count, created_at: @created_at } end |