Class: Legion::Extensions::Agentic::Learning::MetaLearning::Helpers::Strategy
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Learning::MetaLearning::Helpers::Strategy
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb
Constant Summary
Constants included from Constants
Constants::DEFAULT_LEARNING_RATE, Constants::EFFICIENCY_LABELS, Constants::MAX_DOMAINS, Constants::MAX_EPISODES, Constants::MAX_STRATEGIES, Constants::PROFICIENCY_LABELS, Constants::RATE_BOOST, Constants::RATE_DECAY, Constants::STRATEGY_TYPES, Constants::TRANSFER_BONUS
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domains_used ⇒ Object
readonly
Returns the value of attribute domains_used.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#strategy_type ⇒ Object
readonly
Returns the value of attribute strategy_type.
-
#success_count ⇒ Object
readonly
Returns the value of attribute success_count.
-
#usage_count ⇒ Object
readonly
Returns the value of attribute usage_count.
Instance Method Summary collapse
-
#initialize(name:, strategy_type:) ⇒ Strategy
constructor
A new instance of Strategy.
- #success_rate ⇒ Object
- #to_h ⇒ Object
- #use!(success:, domain_name: nil) ⇒ Object
- #versatility ⇒ Object
Constructor Details
#initialize(name:, strategy_type:) ⇒ Strategy
Returns a new instance of Strategy.
17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 17 def initialize(name:, strategy_type:) @id = SecureRandom.uuid @name = name @strategy_type = strategy_type @usage_count = 0 @success_count = 0 @domains_used = [] @created_at = Time.now.utc end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def created_at @created_at end |
#domains_used ⇒ Object (readonly)
Returns the value of attribute domains_used.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def domains_used @domains_used end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def name @name end |
#strategy_type ⇒ Object (readonly)
Returns the value of attribute strategy_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def strategy_type @strategy_type end |
#success_count ⇒ Object (readonly)
Returns the value of attribute success_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def success_count @success_count end |
#usage_count ⇒ Object (readonly)
Returns the value of attribute usage_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 14 def usage_count @usage_count end |
Instance Method Details
#success_rate ⇒ Object
33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 33 def success_rate return 0.0 if @usage_count.zero? (@success_count.to_f / @usage_count).round(10) end |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 43 def to_h { id: @id, name: @name, strategy_type: @strategy_type, usage_count: @usage_count, success_count: @success_count, success_rate: success_rate, versatility: versatility, domains_used: @domains_used, created_at: @created_at } end |
#use!(success:, domain_name: nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 27 def use!(success:, domain_name: nil) @usage_count += 1 @success_count += 1 if success @domains_used << domain_name if domain_name && !@domains_used.include?(domain_name) end |
#versatility ⇒ Object
39 40 41 |
# File 'lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb', line 39 def versatility @domains_used.uniq.size end |