67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
import numpy as np
|
|
import pandas as pd
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
from decoders import proximal, maximum_likelihood
|
|
from utility import simulation, codes
|
|
|
|
|
|
def simulate_new(sim_mgr: simulation.SimulationManager) -> None:
|
|
# H = codes.read_alist_file("res/204.3.486.alist")
|
|
# H = codes.read_alist_file("res/204.55.187.alist")
|
|
# H = codes.read_alist_file("res/96.3.965.alist")
|
|
# H = codes.read_alist_file("res/408.33.844.alist")
|
|
# H = codes.read_alist_file("res/PEGReg252x504.alist")
|
|
# H = codes.read_alist_file("res/999.111.3.5543.alist")
|
|
# H = codes.read_alist_file("res/999.111.3.5565.alist")
|
|
H = codes.read_alist_file("res/816.1A4.845.alist")
|
|
k = 272
|
|
n = 816
|
|
|
|
decoders = [
|
|
proximal.ProximalDecoder(H, gamma=0.01),
|
|
proximal.ProximalDecoder(H, gamma=0.05),
|
|
proximal.ProximalDecoder(H, gamma=0.15)
|
|
]
|
|
|
|
sim = simulation.Simulator(n=n, k=k, decoders=decoders, target_frame_errors=100, SNRs=np.arange(1, 6, 0.5))
|
|
sim_mgr.set_simulator(sim)
|
|
sim_mgr.start()
|
|
|
|
SNRs, BERs = sim_mgr.get_current_results()
|
|
|
|
df = pd.DataFrame({"SNR": SNRs})
|
|
df["BER_prox_0_01"] = BERs[0]
|
|
df["BER_prox_0_05"] = BERs[1]
|
|
df["BER_prox_0_15"] = BERs[2]
|
|
|
|
df.to_csv(f"sim_results/816.1A4.845.csv")
|
|
|
|
|
|
def main():
|
|
Path("sim_results").mkdir(parents=True, exist_ok=True)
|
|
|
|
sim_mgr = simulation.SimulationManager(results_dir="sim_results", save_dir="sim_saves")
|
|
|
|
if sim_mgr.unfinished_simulation_present():
|
|
print("Found unfinished simulation. Picking up where it was left of")
|
|
sim_mgr.load_unfinished()
|
|
sim_mgr.start()
|
|
|
|
SNRs, BERs = sim_mgr.get_current_results()
|
|
|
|
df = pd.DataFrame({"SNR": SNRs})
|
|
# df["ML"] = BERs[0]
|
|
df["decoder0"] = BERs[0]
|
|
df["decoder1"] = BERs[1]
|
|
df["decoder2"] = BERs[2]
|
|
|
|
df.to_csv(f"sim_results/paused.csv")
|
|
else:
|
|
simulate_new(sim_mgr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|