Class: Legion::Extensions::Agentic::Social::MoralReasoning::Helpers::MoralFoundation
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::MoralReasoning::Helpers::MoralFoundation
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb
Constant Summary
Constants included from Constants
Constants::DECAY_RATE, Constants::DEFAULT_WEIGHT, Constants::ETHICAL_FRAMEWORKS, Constants::KOHLBERG_LEVELS, Constants::KOHLBERG_STAGES, Constants::MAX_DILEMMAS, Constants::MAX_HISTORY, Constants::MAX_PRINCIPLES, Constants::MORAL_FOUNDATIONS, Constants::REINFORCEMENT_RATE, Constants::SEVERITY_LABELS, Constants::WEIGHT_CEILING, Constants::WEIGHT_FLOOR
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#sensitivity ⇒ Object
readonly
Returns the value of attribute sensitivity.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #decay ⇒ Object
-
#initialize(id:, weight: DEFAULT_WEIGHT, sensitivity: DEFAULT_WEIGHT) ⇒ MoralFoundation
constructor
A new instance of MoralFoundation.
- #reinforce(amount: 1.0) ⇒ Object
- #to_h ⇒ Object
- #weaken(amount: 1.0) ⇒ Object
Constructor Details
#initialize(id:, weight: DEFAULT_WEIGHT, sensitivity: DEFAULT_WEIGHT) ⇒ MoralFoundation
Returns a new instance of MoralFoundation.
14 15 16 17 18 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 14 def initialize(id:, weight: DEFAULT_WEIGHT, sensitivity: DEFAULT_WEIGHT) @id = id @weight = weight.clamp(WEIGHT_FLOOR, WEIGHT_CEILING) @sensitivity = sensitivity.clamp(0.0, 1.0) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 12 def id @id end |
#sensitivity ⇒ Object (readonly)
Returns the value of attribute sensitivity.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 12 def sensitivity @sensitivity end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 12 def weight @weight end |
Instance Method Details
#decay ⇒ Object
28 29 30 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 28 def decay @weight = (@weight - DECAY_RATE).clamp(WEIGHT_FLOOR, WEIGHT_CEILING) end |
#reinforce(amount: 1.0) ⇒ Object
20 21 22 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 20 def reinforce(amount: 1.0) @weight = (@weight + (amount * REINFORCEMENT_RATE)).clamp(WEIGHT_FLOOR, WEIGHT_CEILING) end |
#to_h ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 32 def to_h { id: @id, weight: @weight, sensitivity: @sensitivity } end |
#weaken(amount: 1.0) ⇒ Object
24 25 26 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/moral_foundation.rb', line 24 def weaken(amount: 1.0) @weight = (@weight - (amount * REINFORCEMENT_RATE)).clamp(WEIGHT_FLOOR, WEIGHT_CEILING) end |