Class: Legion::Extensions::Agentic::Social::SocialLearning::Helpers::ObservedBehavior
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::SocialLearning::Helpers::ObservedBehavior
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb
Constant Summary
Constants included from Constants
Constants::ATTENTION_THRESHOLD, Constants::DEFAULT_PRESTIGE, Constants::LEARNING_STAGES, Constants::MAX_BEHAVIORS, Constants::MAX_HISTORY, Constants::MAX_MODELS, Constants::MAX_OBSERVATIONS, Constants::MODEL_LABELS, Constants::OUTCOME_TYPES, Constants::PRESTIGE_CEILING, Constants::PRESTIGE_FLOOR, Constants::PRESTIGE_LEARNING_RATE, Constants::PUNISHMENT_PENALTY, Constants::REINFORCEMENT_BOOST, Constants::REPRODUCTION_CONFIDENCE, Constants::RETENTION_DECAY, Constants::STALE_THRESHOLD
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#model_agent_id ⇒ Object
readonly
Returns the value of attribute model_agent_id.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#reproduced ⇒ Object
Returns the value of attribute reproduced.
-
#retention ⇒ Object
Returns the value of attribute retention.
Instance Method Summary collapse
- #decay_retention! ⇒ Object
-
#initialize(model_agent_id:, action:, domain:, outcome:, context: {}) ⇒ ObservedBehavior
constructor
A new instance of ObservedBehavior.
- #retained? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(model_agent_id:, action:, domain:, outcome:, context: {}) ⇒ ObservedBehavior
Returns a new instance of ObservedBehavior.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 18 def initialize(model_agent_id:, action:, domain:, outcome:, context: {}) @id = SecureRandom.uuid @model_agent_id = model_agent_id @action = action @domain = domain @context = context @outcome = outcome @retention = 1.0 @reproduced = false @created_at = Time.now.utc end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def action @action end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def id @id end |
#model_agent_id ⇒ Object (readonly)
Returns the value of attribute model_agent_id.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def model_agent_id @model_agent_id end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
14 15 16 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 14 def outcome @outcome end |
#reproduced ⇒ Object
Returns the value of attribute reproduced.
16 17 18 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 16 def reproduced @reproduced end |
#retention ⇒ Object
Returns the value of attribute retention.
16 17 18 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 16 def retention @retention end |
Instance Method Details
#decay_retention! ⇒ Object
30 31 32 33 34 35 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 30 def decay_retention! @retention = (@retention - Constants::RETENTION_DECAY).clamp( Constants::PRESTIGE_FLOOR, Constants::PRESTIGE_CEILING ) end |
#retained? ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 37 def retained? @retention >= Constants::REPRODUCTION_CONFIDENCE end |
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/legion/extensions/agentic/social/social_learning/helpers/observed_behavior.rb', line 41 def to_h { id: @id, model_agent_id: @model_agent_id, action: @action, domain: @domain, context: @context, outcome: @outcome, retention: @retention.round(4), reproduced: @reproduced, retained: retained?, created_at: @created_at } end |