Class: RoadForest::SourceRigor::CredenceAnnealer
- Inherits:
-
Object
- Object
- RoadForest::SourceRigor::CredenceAnnealer
- Defined in:
- lib/roadforest/source-rigor/credence-annealer.rb
Instance Attribute Summary collapse
-
#attempts ⇒ Object
Returns the value of attribute attempts.
Instance Method Summary collapse
-
#initialize(graph) ⇒ CredenceAnnealer
constructor
A new instance of CredenceAnnealer.
- #resolve(&block) ⇒ Object
Constructor Details
#initialize(graph) ⇒ CredenceAnnealer
Returns a new instance of CredenceAnnealer.
5 6 7 8 |
# File 'lib/roadforest/source-rigor/credence-annealer.rb', line 5 def initialize(graph) @graph = graph @attempts = 5 end |
Instance Attribute Details
#attempts ⇒ Object
Returns the value of attribute attempts.
10 11 12 |
# File 'lib/roadforest/source-rigor/credence-annealer.rb', line 10 def attempts @attempts end |
Instance Method Details
#resolve(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/roadforest/source-rigor/credence-annealer.rb', line 12 def resolve(&block) attempts = @attempts @graph.force_impulse begin raise "Annealing failed after #@attempts attempts" if (attempts -= 1) < 0 @graph.next_impulse block.call end until @graph.quiet_impulse? end |