Class: Legion::Extensions::Agentic::Executive::FlexibilityTraining::Helpers::SwitchTrial
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::FlexibilityTraining::Helpers::SwitchTrial
- Defined in:
- lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#from_task_id ⇒ Object
readonly
Returns the value of attribute from_task_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#switch_cost ⇒ Object
readonly
Returns the value of attribute switch_cost.
-
#to_task_id ⇒ Object
readonly
Returns the value of attribute to_task_id.
Instance Method Summary collapse
- #costly? ⇒ Boolean
-
#initialize(from_task_id:, to_task_id:, switch_cost:, accuracy:) ⇒ SwitchTrial
constructor
A new instance of SwitchTrial.
- #successful? ⇒ Boolean
- #switch_cost_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(from_task_id:, to_task_id:, switch_cost:, accuracy:) ⇒ SwitchTrial
Returns a new instance of SwitchTrial.
14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 14 def initialize(from_task_id:, to_task_id:, switch_cost:, accuracy:) @id = SecureRandom.uuid @from_task_id = from_task_id @to_task_id = to_task_id @switch_cost = switch_cost.clamp(0.0, 1.0).round(10) @accuracy = accuracy.clamp(0.0, 1.0).round(10) @created_at = Time.now.utc end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 12 def accuracy @accuracy end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 12 def created_at @created_at end |
#from_task_id ⇒ Object (readonly)
Returns the value of attribute from_task_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 12 def from_task_id @from_task_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 12 def id @id end |
#switch_cost ⇒ Object (readonly)
Returns the value of attribute switch_cost.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 12 def switch_cost @switch_cost end |
#to_task_id ⇒ Object (readonly)
Returns the value of attribute to_task_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 12 def to_task_id @to_task_id end |
Instance Method Details
#costly? ⇒ Boolean
23 24 25 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 23 def costly? @switch_cost > 0.5 end |
#successful? ⇒ Boolean
27 28 29 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 27 def successful? @accuracy > 0.7 end |
#switch_cost_label ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 31 def switch_cost_label Constants.label_for(@switch_cost, Constants::SWITCH_COST_LABELS) end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb', line 35 def to_h { id: @id, from_task_id: @from_task_id, to_task_id: @to_task_id, switch_cost: @switch_cost, accuracy: @accuracy, costly: costly?, successful: successful?, switch_cost_label: switch_cost_label, created_at: @created_at } end |