Class: Ibex::Runtime::RepairPolicy
- Inherits:
-
Object
- Object
- Ibex::Runtime::RepairPolicy
- Defined in:
- lib/ibex/runtime/repair.rb
Overview
Explicit bounded cost and search policy for automatic token repair.
Instance Attribute Summary collapse
-
#delete_cost ⇒ Object
readonly
: Integer.
-
#insert_cost ⇒ Object
readonly
: Integer.
-
#max_configurations ⇒ Object
readonly
: Integer.
-
#max_cost ⇒ Object
readonly
: Integer.
-
#max_lookahead ⇒ Object
readonly
: Integer.
-
#max_stack ⇒ Object
readonly
: Integer.
-
#replace_cost ⇒ Object
readonly
: Integer.
-
#success_shifts ⇒ Object
readonly
: Integer.
Instance Method Summary collapse
-
#initialize(insert_cost: 1, delete_cost: 1, replace_cost: 2, max_cost: 3, max_configurations: 5_000, max_lookahead: 8, success_shifts: 3, max_stack: 256) ⇒ RepairPolicy
constructor
A new instance of RepairPolicy.
Constructor Details
#initialize(insert_cost: 1, delete_cost: 1, replace_cost: 2, max_cost: 3, max_configurations: 5_000, max_lookahead: 8, success_shifts: 3, max_stack: 256) ⇒ RepairPolicy
Returns a new instance of RepairPolicy.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ibex/runtime/repair.rb', line 20 def initialize(insert_cost: 1, delete_cost: 1, replace_cost: 2, max_cost: 3, max_configurations: 5_000, max_lookahead: 8, success_shifts: 3, max_stack: 256) values = { insert_cost: insert_cost, delete_cost: delete_cost, replace_cost: replace_cost, max_cost: max_cost, max_configurations: max_configurations, max_lookahead: max_lookahead, success_shifts: success_shifts, max_stack: max_stack } invalid = values.find { |_name, value| !value.is_a?(Integer) || !value.positive? } raise ArgumentError, "#{invalid.first} must be a positive integer" if invalid raise ArgumentError, "success_shifts must not exceed max_lookahead" if success_shifts > max_lookahead values.each { |name, value| instance_variable_set(:"@#{name}", value) } freeze end |
Instance Attribute Details
#delete_cost ⇒ Object (readonly)
: Integer
9 10 11 |
# File 'lib/ibex/runtime/repair.rb', line 9 def delete_cost @delete_cost end |
#insert_cost ⇒ Object (readonly)
: Integer
8 9 10 |
# File 'lib/ibex/runtime/repair.rb', line 8 def insert_cost @insert_cost end |
#max_configurations ⇒ Object (readonly)
: Integer
12 13 14 |
# File 'lib/ibex/runtime/repair.rb', line 12 def max_configurations @max_configurations end |
#max_cost ⇒ Object (readonly)
: Integer
11 12 13 |
# File 'lib/ibex/runtime/repair.rb', line 11 def max_cost @max_cost end |
#max_lookahead ⇒ Object (readonly)
: Integer
13 14 15 |
# File 'lib/ibex/runtime/repair.rb', line 13 def max_lookahead @max_lookahead end |
#max_stack ⇒ Object (readonly)
: Integer
15 16 17 |
# File 'lib/ibex/runtime/repair.rb', line 15 def max_stack @max_stack end |
#replace_cost ⇒ Object (readonly)
: Integer
10 11 12 |
# File 'lib/ibex/runtime/repair.rb', line 10 def replace_cost @replace_cost end |
#success_shifts ⇒ Object (readonly)
: Integer
14 15 16 |
# File 'lib/ibex/runtime/repair.rb', line 14 def success_shifts @success_shifts end |