diff --git a/sw/decoders/naive_soft_decision.py b/sw/decoders/maximum_likelihood.py similarity index 98% rename from sw/decoders/naive_soft_decision.py rename to sw/decoders/maximum_likelihood.py index 4ae0735..09ccf5d 100644 --- a/sw/decoders/naive_soft_decision.py +++ b/sw/decoders/maximum_likelihood.py @@ -4,7 +4,7 @@ import itertools # TODO: Unify the interface regarding [0, 1]^n and [-1, 1]^n -class SoftDecisionDecoder: +class MLDecoder: """This class naively implements a soft decision decoder. The decoder calculates the correlation between the received signal and each codeword and then chooses the one with the largest correlation. diff --git a/sw/main.py b/sw/main.py index 59354b9..7786cc8 100644 --- a/sw/main.py +++ b/sw/main.py @@ -8,8 +8,8 @@ import os from itertools import chain from timeit import default_timer -from decoders import proximal, naive_soft_decision -from utility import simulations, encoders, codes +from decoders import proximal, maximum_likelihood +from utility import simulations, codes def test_decoders(G, decoders: typing.List) -> pd.DataFrame: @@ -27,7 +27,7 @@ def test_decoders(G, decoders: typing.List) -> pd.DataFrame: decoder=decoder, SNRs=SNRs, target_bit_errors=100, - N_max=30000) + N_max=50000) data[f"BER_{decoder_name}"] = BERs_sd @@ -91,10 +91,10 @@ def main(): H = codes.get_systematic_H(G) decoders = { - "naive_soft_decision": naive_soft_decision.SoftDecisionDecoder(G, H), - "proximal_0_01": proximal.ProximalDecoder(H, K=100, gamma=0.01), - "proximal_0_05": proximal.ProximalDecoder(H, K=100, gamma=0.05), - "proximal_0_15": proximal.ProximalDecoder(H, K=100, gamma=0.15), + "naive_soft_decision": maximum_likelihood.MLDecoder(G, H), + "proximal_0_01": proximal.ProximalDecoder(H, gamma=0.01), + "proximal_0_05": proximal.ProximalDecoder(H, gamma=0.05), + "proximal_0_15": proximal.ProximalDecoder(H, gamma=0.15), } data = test_decoders(G, decoders) diff --git a/sw/test/test_soft_decision.py b/sw/test/test_soft_decision.py index ed84ef4..d0c93d6 100644 --- a/sw/test/test_soft_decision.py +++ b/sw/test/test_soft_decision.py @@ -1,6 +1,6 @@ import unittest import numpy as np -from decoders import naive_soft_decision +from decoders import maximum_likelihood class CodewordGenerationTestCase(unittest.TestCase): @@ -14,12 +14,8 @@ class CodewordGenerationTestCase(unittest.TestCase): H = np.array([[1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 1]]) - R = np.array([[0, 0, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 0, 0], - [0, 0, 0, 0, 0, 1, 0], - [0, 0, 0, 0, 0, 0, 1]]) - decoder = naive_soft_decision.SoftDecisionDecoder(G, H, R) + decoder = maximum_likelihood.MLDecoder(G, H) expected_datawords = np.array([[0, 0, 0, 0], [0, 0, 0, 1], diff --git a/sw/test/test_utility.py b/sw/test/test_utility.py index b309a4b..7a07b65 100644 --- a/sw/test/test_utility.py +++ b/sw/test/test_utility.py @@ -58,23 +58,6 @@ class CodesTestCase(unittest.TestCase): self.assertEqual(np.array_equal(expected_H, H), True) - def test_get_systematic_R(self): - # Hamming(7,4) code - - G = np.array([[1, 0, 0, 0, 0, 1, 1], - [0, 1, 0, 0, 1, 0, 1], - [0, 0, 1, 0, 1, 1, 0], - [0, 0, 0, 1, 1, 1, 1]]) - - expected_R = G = np.array([[1, 0, 0, 0, 0, 0, 0], - [0, 1, 0, 0, 0, 0, 0], - [0, 0, 1, 0, 0, 0, 0], - [0, 0, 0, 1, 0, 0, 0]]) - - R = codes.get_systematic_R(G) - - self.assertEqual(np.array_equal(expected_R, R), True) - if __name__ == '__main__': unittest.main()