Renamed naive soft decision to maximum likelihood; Removed reference to R matrix
This commit is contained in:
parent
5865a8683f
commit
f29c2e71de
@ -4,7 +4,7 @@ import itertools
|
|||||||
|
|
||||||
|
|
||||||
# TODO: Unify the interface regarding [0, 1]^n and [-1, 1]^n
|
# 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
|
"""This class naively implements a soft decision decoder. The decoder calculates
|
||||||
the correlation between the received signal and each codeword and then chooses the
|
the correlation between the received signal and each codeword and then chooses the
|
||||||
one with the largest correlation.
|
one with the largest correlation.
|
||||||
14
sw/main.py
14
sw/main.py
@ -8,8 +8,8 @@ import os
|
|||||||
from itertools import chain
|
from itertools import chain
|
||||||
from timeit import default_timer
|
from timeit import default_timer
|
||||||
|
|
||||||
from decoders import proximal, naive_soft_decision
|
from decoders import proximal, maximum_likelihood
|
||||||
from utility import simulations, encoders, codes
|
from utility import simulations, codes
|
||||||
|
|
||||||
|
|
||||||
def test_decoders(G, decoders: typing.List) -> pd.DataFrame:
|
def test_decoders(G, decoders: typing.List) -> pd.DataFrame:
|
||||||
@ -27,7 +27,7 @@ def test_decoders(G, decoders: typing.List) -> pd.DataFrame:
|
|||||||
decoder=decoder,
|
decoder=decoder,
|
||||||
SNRs=SNRs,
|
SNRs=SNRs,
|
||||||
target_bit_errors=100,
|
target_bit_errors=100,
|
||||||
N_max=30000)
|
N_max=50000)
|
||||||
|
|
||||||
data[f"BER_{decoder_name}"] = BERs_sd
|
data[f"BER_{decoder_name}"] = BERs_sd
|
||||||
|
|
||||||
@ -91,10 +91,10 @@ def main():
|
|||||||
H = codes.get_systematic_H(G)
|
H = codes.get_systematic_H(G)
|
||||||
|
|
||||||
decoders = {
|
decoders = {
|
||||||
"naive_soft_decision": naive_soft_decision.SoftDecisionDecoder(G, H),
|
"naive_soft_decision": maximum_likelihood.MLDecoder(G, H),
|
||||||
"proximal_0_01": proximal.ProximalDecoder(H, K=100, gamma=0.01),
|
"proximal_0_01": proximal.ProximalDecoder(H, gamma=0.01),
|
||||||
"proximal_0_05": proximal.ProximalDecoder(H, K=100, gamma=0.05),
|
"proximal_0_05": proximal.ProximalDecoder(H, gamma=0.05),
|
||||||
"proximal_0_15": proximal.ProximalDecoder(H, K=100, gamma=0.15),
|
"proximal_0_15": proximal.ProximalDecoder(H, gamma=0.15),
|
||||||
}
|
}
|
||||||
|
|
||||||
data = test_decoders(G, decoders)
|
data = test_decoders(G, decoders)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from decoders import naive_soft_decision
|
from decoders import maximum_likelihood
|
||||||
|
|
||||||
|
|
||||||
class CodewordGenerationTestCase(unittest.TestCase):
|
class CodewordGenerationTestCase(unittest.TestCase):
|
||||||
@ -14,12 +14,8 @@ class CodewordGenerationTestCase(unittest.TestCase):
|
|||||||
H = np.array([[1, 0, 1, 0, 1, 0, 1],
|
H = np.array([[1, 0, 1, 0, 1, 0, 1],
|
||||||
[0, 1, 1, 0, 0, 1, 1],
|
[0, 1, 1, 0, 0, 1, 1],
|
||||||
[0, 0, 0, 1, 1, 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],
|
expected_datawords = np.array([[0, 0, 0, 0],
|
||||||
[0, 0, 0, 1],
|
[0, 0, 0, 1],
|
||||||
|
|||||||
@ -58,23 +58,6 @@ class CodesTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(np.array_equal(expected_H, H), True)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user