Modified main to work with new simulator interface
This commit is contained in:
parent
9beda2231d
commit
37edb9a6e9
77
sw/main.py
77
sw/main.py
@ -7,59 +7,46 @@ 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_name = "test"
|
||||
|
||||
sim_mgr = simulation.SimulationManager(results_dir="sim_results", save_dir="sim_saves")
|
||||
|
||||
if sim_mgr.unfinished_simulation_present():
|
||||
if sim_mgr.unfinished_simulation_present(sim_name):
|
||||
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")
|
||||
sim_mgr.load_unfinished(sim_name=sim_name)
|
||||
sim_mgr.simulate()
|
||||
else:
|
||||
simulate_new(sim_mgr)
|
||||
# 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)
|
||||
]
|
||||
|
||||
labels = [
|
||||
"proximal $\\gamma = 0.01$",
|
||||
"proximal $\\gamma = 0.05$",
|
||||
"proximal $\\gamma = 0.15$"
|
||||
]
|
||||
|
||||
sim = simulation.Simulator(n=n, k=k, decoders=decoders, target_frame_errors=3, SNRs=np.arange(1, 6, 0.5))
|
||||
|
||||
sim_mgr.configure_simulation(simulator=sim, name=sim_name, column_labels=labels)
|
||||
sim_mgr.simulate()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user