Class: Legion::Extensions::Agentic::Attention::Surprise::Helpers::HabituationModel
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Surprise::Helpers::HabituationModel
- Defined in:
- lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb
Instance Method Summary collapse
- #decay_all ⇒ Object
- #habituate(domain) ⇒ Object
-
#initialize ⇒ HabituationModel
constructor
A new instance of HabituationModel.
- #sensitivity_for(domain) ⇒ Object
- #sensitize(domain) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ HabituationModel
Returns a new instance of HabituationModel.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb', line 10 def initialize @levels = {} end |
Instance Method Details
#decay_all ⇒ Object
34 35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb', line 34 def decay_all @levels.each_key do |domain| current = @levels[domain] @levels[domain] = [current + (Constants::SENSITIZATION_RATE * 0.5), 1.0].min end end |
#habituate(domain) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb', line 18 def habituate(domain) current = sensitivity_for(domain) floor = Constants::DOMAIN_HABITUATION_FLOOR updated = [current - Constants::HABITUATION_RATE, floor].max @levels[domain] = updated enforce_domain_limit updated end |
#sensitivity_for(domain) ⇒ Object
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb', line 14 def sensitivity_for(domain) @levels.fetch(domain, 1.0) end |
#sensitize(domain) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb', line 27 def sensitize(domain) current = sensitivity_for(domain) updated = [current + Constants::SENSITIZATION_RATE, 1.0].min @levels[domain] = updated updated end |
#to_h ⇒ Object
41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/habituation_model.rb', line 41 def to_h { domains: @levels.size, sensitivities: @levels.transform_values { |v| v.round(4) } } end |