Class: Legion::Extensions::Agentic::Inference::Intuition::Helpers::Heuristic
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::Intuition::Helpers::Heuristic
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb
Constant Summary
Constants included from Constants
Constants::CONFIDENCE_CEILING, Constants::CONFIDENCE_FLOOR, Constants::CONFIDENCE_LABELS, Constants::DECAY_RATE, Constants::DEFAULT_CONFIDENCE, Constants::HEURISTIC_TYPES, Constants::INTUITION_MODES, Constants::MAX_HEURISTICS, Constants::MAX_HISTORY, Constants::MAX_PATTERNS, Constants::PATTERN_STATES, Constants::RECOGNITION_THRESHOLD, Constants::REINFORCEMENT_RATE, Constants::SPEED_MULTIPLIER, Constants::STATE_THRESHOLDS
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#heuristic_type ⇒ Object
readonly
Returns the value of attribute heuristic_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#successes ⇒ Object
readonly
Returns the value of attribute successes.
-
#uses ⇒ Object
readonly
Returns the value of attribute uses.
Instance Method Summary collapse
- #apply ⇒ Object
- #effective? ⇒ Boolean
-
#initialize(id:, name:, heuristic_type:, domain: :general) ⇒ Heuristic
constructor
A new instance of Heuristic.
- #record_outcome(success:) ⇒ Object
- #success_rate ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(id:, name:, heuristic_type:, domain: :general) ⇒ Heuristic
Returns a new instance of Heuristic.
14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 14 def initialize(id:, name:, heuristic_type:, domain: :general) @id = id @name = name @heuristic_type = resolve_type(heuristic_type) @domain = domain @uses = 0 @successes = 0 end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 12 def domain @domain end |
#heuristic_type ⇒ Object (readonly)
Returns the value of attribute heuristic_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 12 def heuristic_type @heuristic_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 12 def name @name end |
#successes ⇒ Object (readonly)
Returns the value of attribute successes.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 12 def successes @successes end |
#uses ⇒ Object (readonly)
Returns the value of attribute uses.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 12 def uses @uses end |
Instance Method Details
#apply ⇒ Object
23 24 25 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 23 def apply @uses += 1 end |
#effective? ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 37 def effective? @uses >= 3 && success_rate >= 0.6 end |
#record_outcome(success:) ⇒ Object
27 28 29 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 27 def record_outcome(success:) @successes += 1 if success end |
#success_rate ⇒ Object
31 32 33 34 35 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 31 def success_rate return 0.0 if @uses.zero? @successes.to_f / @uses end |
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb', line 41 def to_h { id: @id, name: @name, heuristic_type: @heuristic_type, domain: @domain, uses: @uses, successes: @successes, success_rate: success_rate.round(4), effective: effective? } end |