Changed main.py to work with new utility.codes
This commit is contained in:
parent
b4623580af
commit
d8258a36f6
32
sw/main.py
32
sw/main.py
@ -5,31 +5,26 @@ import pandas as pd
|
||||
from timeit import default_timer as timer
|
||||
|
||||
from decoders import proximal, naive_soft_decision
|
||||
from utility import noise, simulations, encoders
|
||||
from utility import noise, simulations, encoders, codes
|
||||
|
||||
|
||||
def main():
|
||||
# Hamming(7,4) code
|
||||
# used_code = "Hamming_7_4"
|
||||
# used_code = "Golay_24_12"
|
||||
# used_code = "BCH_31_16"
|
||||
# used_code = "BCH_31_21"
|
||||
used_code = "BCH_63_16"
|
||||
|
||||
G = np.array([[1, 1, 1, 0, 0, 0, 0],
|
||||
[1, 0, 0, 1, 1, 0, 0],
|
||||
[0, 1, 0, 1, 0, 1, 0],
|
||||
[1, 1, 0, 1, 0, 0, 1]])
|
||||
|
||||
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]])
|
||||
G = codes.Gs[used_code]
|
||||
H = codes.get_systematic_H(G)
|
||||
R = codes.get_systematic_R(G)
|
||||
|
||||
# Define encoder and decoders
|
||||
|
||||
encoder = encoders.Encoder(G)
|
||||
|
||||
decoders = {"naive_soft_decision": naive_soft_decision.SoftDecisionDecoder(G, H, R),
|
||||
decoders = {
|
||||
# "naive_soft_decision": naive_soft_decision.SoftDecisionDecoder(G, H, R),
|
||||
"proximal_0_01": proximal.ProximalDecoder(H, R, K=100, gamma=0.01),
|
||||
"proximal_0_05": proximal.ProximalDecoder(H, R, K=100, gamma=0.05),
|
||||
"proximal_0_15": proximal.ProximalDecoder(H, R, K=100, gamma=0.15),
|
||||
@ -51,7 +46,8 @@ def main():
|
||||
decoder=decoder,
|
||||
d=d,
|
||||
SNRs=SNRs,
|
||||
N_max=2000)
|
||||
target_bit_errors=500,
|
||||
N_max=10000)
|
||||
|
||||
data[f"BER_{decoder_name}"] = BERs_sd
|
||||
|
||||
@ -68,7 +64,7 @@ def main():
|
||||
for decoder_name in decoders:
|
||||
ax = sns.lineplot(data=data, x="SNR", y=f"BER_{decoder_name}", label=f"{decoder_name}")
|
||||
|
||||
ax.set_title("Hamming(7,4) Code")
|
||||
ax.set_title(used_code)
|
||||
ax.set(yscale="log")
|
||||
ax.set_yticks([10e-5, 10e-4, 10e-3, 10e-2, 10e-1, 10e0])
|
||||
ax.legend()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user