Rewrote main to use SimulationManger
This commit is contained in:
parent
e9faba01d2
commit
5d14b383af
75
sw/main.py
75
sw/main.py
@ -2,14 +2,12 @@ import numpy as np
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import seaborn as sns
|
import seaborn as sns
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import typing
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
from itertools import chain
|
import sys
|
||||||
from timeit import default_timer
|
|
||||||
|
|
||||||
from decoders import proximal, maximum_likelihood
|
from decoders import proximal, maximum_likelihood
|
||||||
from utility import simulations, codes, visualization
|
from utility import simulation, codes, visualization
|
||||||
|
|
||||||
|
|
||||||
# TODO: Fix spacing between axes and margins
|
# TODO: Fix spacing between axes and margins
|
||||||
@ -33,34 +31,47 @@ def plot_results():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Path("sim_results").mkdir(parents=True, exist_ok=True)
|
Path("sim_results").mkdir(parents=True, exist_ok=True)
|
||||||
#
|
|
||||||
# # used_code = "Hamming_7_4"
|
sys.setrecursionlimit(10 * sys.getrecursionlimit())
|
||||||
# # used_code = "Golay_24_12"
|
|
||||||
# used_code = "BCH_31_16"
|
sim_mgr = simulation.SimulationManager(results_dir="sim_results", save_dir="sim_saves")
|
||||||
# # used_code = "BCH_31_21"
|
|
||||||
# # used_code = "BCH_63_16"
|
if sim_mgr.unfinished_simulation_present():
|
||||||
#
|
print("Found unfinished simulation. Picking up where it was left of")
|
||||||
# G = codes.Gs[used_code]
|
sim_mgr.load_unfinished()
|
||||||
# H = codes.get_systematic_H(G)
|
sim_mgr.start()
|
||||||
#
|
else:
|
||||||
# decoders = [
|
print("No unfinished simulation present. Starting a new one")
|
||||||
# maximum_likelihood.MLDecoder(G, H),
|
|
||||||
# proximal.ProximalDecoder(H, gamma=0.01),
|
used_code = "Golay_24_12"
|
||||||
# proximal.ProximalDecoder(H, gamma=0.05),
|
|
||||||
# proximal.ProximalDecoder(H, gamma=0.15)
|
G = codes.Gs[used_code]
|
||||||
# ]
|
H = codes.get_systematic_H(G)
|
||||||
#
|
|
||||||
# k, n = G.shape
|
decoders = [
|
||||||
# SNRs, BERs = simulations.test_decoders(n, k, decoders, N_max=30000, target_frame_errors=100)
|
# maximum_likelihood.MLDecoder(G, H),
|
||||||
#
|
proximal.ProximalDecoder(H, gamma=0.01),
|
||||||
# df = pd.DataFrame({"SNR": SNRs})
|
proximal.ProximalDecoder(H, gamma=0.05),
|
||||||
# df["BER_ML"] = BERs[0]
|
proximal.ProximalDecoder(H, gamma=0.15)
|
||||||
# df["BER_prox_0_01"] = BERs[0]
|
]
|
||||||
# df["BER_prox_0_05"] = BERs[1]
|
|
||||||
# df["BER_prox_0_15"] = BERs[2]
|
k, n = G.shape
|
||||||
#
|
|
||||||
# df.to_csv(f"sim_results/{used_code}.csv")
|
sim = simulation.Simulator(n=n, k=k, decoders=decoders, SNRs=np.arange(1, 6, 0.5), target_frame_errors=100)
|
||||||
|
|
||||||
|
sim_mgr.set_simulator(sim)
|
||||||
|
sim_mgr.start()
|
||||||
|
|
||||||
|
SNRs, BERs = sim_mgr.get_current_results()
|
||||||
|
|
||||||
|
df = pd.DataFrame({"SNR": SNRs})
|
||||||
|
# df["ML"] = BERs[0]
|
||||||
|
df["prox_0_01"] = BERs[0]
|
||||||
|
df["prox_0_05"] = BERs[1]
|
||||||
|
df["prox_0_15"] = BERs[2]
|
||||||
|
|
||||||
|
df.to_csv(f"sim_results/golay.csv")
|
||||||
|
|
||||||
plot_results()
|
plot_results()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user