Compare commits

..

No commits in common. "fffb15595b7f33195f71a536d7cc93f47551e660" and "5762c602af7e956a8b9c85b433e619c5ffcdf753" have entirely different histories.

2 changed files with 12 additions and 29 deletions

View File

@ -102,7 +102,7 @@ parity constraint. In a similar vein, we can define the following set of
polynomial equations to describe codewords:
$$
F(\bm{x}) = \left[\begin{array}{c}1 - x_1^2 \\ \vdots\\ 1 - x_n^2 \\ 1 - \prod_{i \in A(1)}x_i \\ \vdots\\ 1 - \prod_{i \in A(m)}x_i\end{array}\right] \overset{!}{=} \bm{0}.
F = \left[\begin{array}{c}1 - x_1^2 \\ \vdots\\ 1 - x_n^2 \\ 1 - \prod_{i \in A(1)}x_i \\ \vdots\\ 1 - \prod_{i \in A(m)}x_i\end{array}\right] \overset{!}{=} \bm{0}.
$$
This is a problem we can solve using homotopy continuation.

View File

@ -4,7 +4,6 @@ import galois
import argparse
from dataclasses import dataclass
from tqdm import tqdm
import pandas as pd
# autopep8: off
import sys
@ -48,7 +47,7 @@ def decode(tracker, y, H, args: SimulationArgs) -> np.ndarray:
return x_hat
def simulate_error_rates_for_SNR(H, Eb_N0, args: SimulationArgs) -> typing.Tuple[float, float, float, int]:
def simulate_error_rates_for_SNR(H, Eb_N0, args: SimulationArgs) -> typing.Tuple[np.ndarray, np.ndarray, np.ndarray]:
GF = galois.GF(2)
H_GF = GF(H)
G = H_GF.null_space()
@ -85,29 +84,14 @@ def simulate_error_rates_for_SNR(H, Eb_N0, args: SimulationArgs) -> typing.Tuple
num_frames += 1
if frame_errors >= args.target_frame_errors:
if frame_errors > args.target_frame_errors:
break
BER = bit_errors / (num_frames * n)
FER = frame_errors / num_frames
DFR = decoding_failures / num_frames
return FER, BER, DFR, frame_errors
def simulate_error_rates(H, Eb_N0_list, args: SimulationArgs) -> typing.Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
FERs = []
BERs = []
DFRs = []
frame_errors_list = []
for SNR in Eb_N0_list:
FER, BER, DFR, num_frames = simulate_error_rates_for_SNR(H, SNR, args)
FERs.append(FER)
BERs.append(BER)
DFRs.append(DFR)
frame_errors_list.append(num_frames)
return np.array(FERs), np.array(BERs), np.array(DFRs), np.array(frame_errors_list)
return FER, BER, DFR
def main():
@ -117,10 +101,9 @@ def main():
parser.add_argument("-c", "--code", type=str, required=True,
help="Path to the alist file containing the parity check matrix of the code")
parser.add_argument("--snr", type=float, required=True, nargs=3,
metavar=('start', 'stop', 'step'),
help="SNRs to simulate (Eb/N0) in dB")
# TODO: Extend this script to multiple SRNs
parser.add_argument("--snr", type=float, required=True,
help="Eb/N0 to use for this simulation")
parser.add_argument("--max-frames", type=int, default=int(1e6),
help="Maximum number of frames to simulate")
parser.add_argument("--target-frame-errors", type=int, default=200,
@ -156,12 +139,12 @@ def main():
max_frames=args.max_frames,
target_frame_errors=args.target_frame_errors)
SNRs = np.arange(args.snr[0], args.snr[1], args.snr[2])
FERs, BERs, DFRs, frame_errors_list = simulate_error_rates(
H, SNRs, simulation_args)
FER, BER, DFR = simulate_error_rates_for_SNR(H, args.snr, simulation_args)
print(f"FER: {FER}")
print(f"DFR: {DFR}")
print(f"BER: {BER}")
df = pd.DataFrame({"SNR": SNRs, "FER": FERs, "BER": BERs, "DFR": DFRs, "frame_errors": frame_errors_list})
print(df)
if __name__ == "__main__":
main()