@@ -70,11 +70,6 @@ mutable struct RecordedAlgorithm{Q,A} <: AbstractAlgorithm{Q,A}
7070 end
7171end
7272
73- abstract type Stoppability end
74- struct Stoppable <: Stoppability end
75- struct NotStoppable <: Stoppability end
76- Stoppability (:: AbstractAlgorithm ) = NotStoppable ()
77-
7873
7974"""
8075Initialise
@@ -177,28 +172,32 @@ function progress(ra::RecordedAlgorithm{Q,A}) where {Q,A}
177172 ceil (Int64, output)
178173end
179174
175+ abstract type Stoppability end
176+ struct Stoppable <: Stoppability end
177+ struct NotStoppable <: Stoppability end
178+ Stoppability (:: AbstractAlgorithm ) = NotStoppable ()
179+ """
180+ Return true if the stopping condition has been reached
181+ """
182+ stopnow (ra:: RecordedAlgorithm ) = stopnow (Stoppability (ra. algorithm), ra)
183+ stopnow (:: Stoppable , ra:: RecordedAlgorithm ) = stopnow (ra. algorithm) || stopnow (NotStoppable (), ra)
184+ function stopnow (:: NotStoppable , ra:: RecordedAlgorithm )
185+ (ra. stopat[1 ] ≠ 0 && ra. iteration ≥ ra. stopat[1 ]) ||
186+ (ra. stopat[2 ] ≠ 0 && ra. epoch ≥ ra. stopat[2 ]) ||
187+ (ra. stopat[3 ] ≠ 0 && ra. time ≥ ra. stopat[3 ]) ||
188+ (ra. precision_active && ra. iteration > 1 && ra. precision ≤ ra. stopat[4 ])
189+ end
190+
180191"""
181192Function used in `record` as an argument of `ProgressMeter.next!`
182193"""
183194function generate_showvalues (ra:: RecordedAlgorithm )
184- () -> [(:iterations , ra. iteration), (:epochs , ra. epoch), (:answers , string (ra. answer_count)[6 : end - 1 ])]
195+ () -> append! ( [(:iterations , ra. iteration), (:epochs , ra. epoch), (:answers , string (ra. answer_count)[6 : end - 1 ])], ra . precision_active ? [( :precision , ra . precision)] : [])
185196end
186197
187198"""
188199Compile the results to be outputed
189200"""
190201function report (ra:: RecordedAlgorithm )
191202 (queries= ra. queries, answers= ra. answers, iterations= ra. iterations, epochs= ra. epochs, timestamps= ra. timestamps, answers_origin= ra. answers_origin, answer_count= ra. answer_count, precision= ra. precisions)
192- end
193-
194- """
195- Return true if the stopping condition has been reached
196- """
197- stopnow (ra:: RecordedAlgorithm ) = stopnow (Stoppability (ra. algorithm), ra)
198- stopnow (:: Stoppable , ra:: RecordedAlgorithm )= stopnow (ra. algorithm) || stopnow (NotStoppable (), ra)
199- function stopnow (:: NotStoppable , ra:: RecordedAlgorithm )
200- (ra. stopat[1 ] ≠ 0 && ra. iteration ≥ ra. stopat[1 ]) ||
201- (ra. stopat[2 ] ≠ 0 && ra. epoch ≥ ra. stopat[2 ]) ||
202- (ra. stopat[3 ] ≠ 0 && ra. time ≥ ra. stopat[3 ]) ||
203- (ra. precision_active && length (ra. queries) > 1 && ra. precision ≤ ra. stopat[4 ])
204203end
0 commit comments