Class: Legion::Extensions::Agentic::Attention::Arousal::Helpers::ArousalModel
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Arousal::Helpers::ArousalModel
show all
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb
Constant Summary
Constants included
from Constants
Constants::AROUSAL_ALPHA, Constants::AROUSAL_CEILING, Constants::AROUSAL_FLOOR, Constants::AROUSAL_LABELS, Constants::BOOST_FACTOR, Constants::CALM_FACTOR, Constants::DECAY_RATE, Constants::DEFAULT_AROUSAL, Constants::MAX_AROUSAL_HISTORY, Constants::OPTIMAL_AROUSAL_COMPLEX, Constants::OPTIMAL_AROUSAL_DEFAULT, Constants::OPTIMAL_AROUSAL_SIMPLE, Constants::PERFORMANCE_SENSITIVITY, Constants::TASK_COMPLEXITIES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ArousalModel.
14
15
16
17
18
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 14
def initialize
@arousal = DEFAULT_AROUSAL
@arousal_history = []
@performance_last = 0.0
end
|
Instance Attribute Details
#arousal ⇒ Object
Returns the value of attribute arousal.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 12
def arousal
@arousal
end
|
#arousal_history ⇒ Object
Returns the value of attribute arousal_history.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 12
def arousal_history
@arousal_history
end
|
Returns the value of attribute performance_last.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 12
def performance_last
@performance_last
end
|
Instance Method Details
#arousal_label ⇒ Object
45
46
47
48
49
50
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 45
def arousal_label
AROUSAL_LABELS.each do |range, label|
return label if range.cover?(@arousal)
end
:dormant
end
|
#calm(amount:) ⇒ Object
26
27
28
29
30
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 26
def calm(amount:)
reduction = amount || CALM_FACTOR
raw = @arousal - reduction.to_f.clamp(0.0, 1.0)
update_arousal(raw, source: :calm)
end
|
#decay ⇒ Object
32
33
34
35
36
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 32
def decay
delta = (@arousal - DEFAULT_AROUSAL) * DECAY_RATE
raw = @arousal - delta
update_arousal(raw, source: :decay)
end
|
#optimal_for(complexity) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 38
def performance(task_complexity: :moderate)
optimal = optimal_for(task_complexity)
diff = @arousal - optimal
@performance_last = Math.exp(-PERFORMANCE_SENSITIVITY * (diff**2))
@performance_last
end
|
#stimulate(amount:, source: :unknown) ⇒ Object
20
21
22
23
24
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 20
def stimulate(amount:, source: :unknown)
boost = amount || BOOST_FACTOR
raw = @arousal + boost.to_f.clamp(0.0, 1.0)
update_arousal(raw, source: source)
end
|
#to_h ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/legion/extensions/agentic/attention/arousal/helpers/arousal_model.rb', line 56
def to_h
{
arousal: @arousal,
label: arousal_label,
performance_last: @performance_last,
history_size: @arousal_history.size
}
end
|