Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Added a distinction between decoding_error and decoding_failure, refi…
Browse files Browse the repository at this point in the history
…ned decoding_success_rate accordingly
  • Loading branch information
David Lucas committed May 11, 2016
1 parent 0dfdbf0 commit 7212b33
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/sage/coding/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,16 +704,21 @@ def _perform_experiments_for_single_id(self, identifier, verbosity):
c = C.random_element()
generate_c_time = time.clock() - start
y = Chan(c)
decoding_failure = True
try:
start = time.clock()
dec_y = D.decode_to_code(y)
decode_time = time.clock() - start
decoding_success = True
decoding_error = False
if "list-decoder" in D.decoder_type():
decoding_failure = (c != dec_y)
else:
decoding_failure = (c != dec_y)
except DecodingError:
decode_time = time.clock() - start
dec_y = None #as decoding failed
decoding_success = False
data[identifier, i] = (c, generate_c_time, y, dec_y, decode_time, decoding_success)
decoding_error = True
data[identifier, i] = (c, generate_c_time, y, dec_y, decode_time, decoding_error, decoding_failure)

#verbosity
if verbosity ==1:
Expand Down Expand Up @@ -889,12 +894,19 @@ def compute_timings(self, target, processing, identifier = None):
return self._process_experimental_data(identifier,target, processing)

@cached_method
def decoding_success_rate(self, identifier = None):
def decoding_success_rate(self, target, identifier = None):
r"""
Returns the success rate of the decoding attempts.
INPUT:
- ``target`` -- the operation whose success rate will be computed, can be
either:
- ``"error"``, which will compute a ratio on the number of decoding attempts
which returned a word, whichever word it was
- ``"failure"``, which will compute a ratio on the number of decoding attempts
which returned the original codeword
- ``identifier`` -- (default: ``None``) the identifier of the benchmark
whose success rate will be computed. If it is let to ``None``, success
rate of every subbenchmark will be computed.
Expand All @@ -913,15 +925,18 @@ def decoding_success_rate(self, identifier = None):
sage: Chan = channels.StaticErrorRateChannel(C.ambient_space(), D.decoding_radius())
sage: B = codes.Benchmark(C, D, Chan)
sage: B.run()
sage: B.decoding_success_rate()
sage: B.decoding_success_rate("failure")
{'_0': 1.00}
"""
def compute_success_rate(identifier):
if not target in ("error", "failure"):
raise ValueError("target has to be set to either \"error\" or \"failure\"")
t = (5 if target is "error" else 6)
def compute_success_rate(identifier, target):
i = 0
success_sum = 0
while True:
try:
success_sum += data[identifier, i][5]
success_sum += not(data[identifier, i][target])
i += 1
except KeyError:
break
Expand All @@ -936,10 +951,10 @@ def compute_success_rate(identifier):
elif identifier is None:
rates = dict()
for i in ids:
rates[i] = compute_success_rate(i)
rates[i] = compute_success_rate(i, t)
return rates
elif identifier is not None:
return compute_success_rate(i)
return compute_success_rate(i, t)

def plot(self, points_generator, **kwargs):
r"""
Expand Down

0 comments on commit 7212b33

Please sign in to comment.