Make Homotopy generator use Newton Homotopy
This commit is contained in:
@@ -18,12 +18,14 @@ def track_path(args):
|
||||
[0, 1, 1, 0],
|
||||
[0, 0, 1, 1]])
|
||||
|
||||
homotopy = homotopy_generator.HomotopyGenerator(H)
|
||||
received = np.array([0, 0, 0, 0])
|
||||
|
||||
print(f"G: {homotopy.G}")
|
||||
print(f"F: {homotopy.F}")
|
||||
print(f"H: {homotopy.H}")
|
||||
print(f"DH: {homotopy.DH}")
|
||||
homotopy = homotopy_generator.HomotopyGenerator(H, received)
|
||||
|
||||
# print(f"G: {homotopy.G}")
|
||||
# print(f"F: {homotopy.F}")
|
||||
# print(f"H: {homotopy.H}")
|
||||
# print(f"DH: {homotopy.DH}")
|
||||
|
||||
tracker = path_tracker.PathTracker(homotopy, args.euler_step_size, args.euler_max_tries,
|
||||
args.newton_max_iter, args.newton_convergence_threshold, args.sigma)
|
||||
|
||||
@@ -54,35 +54,35 @@ def simulate_error_rates_for_SNR(H, Eb_N0, args: SimulationArgs) -> typing.Tuple
|
||||
G = H_GF.null_space()
|
||||
k, n = G.shape
|
||||
|
||||
homotopy = homotopy_generator.HomotopyGenerator(H)
|
||||
|
||||
# print(f"G: {homotopy.G}")
|
||||
# print(f"F: {homotopy.F}")
|
||||
# print(f"H: {homotopy.H}")
|
||||
# print(f"DH: {homotopy.DH}")
|
||||
|
||||
tracker = path_tracker.PathTracker(homotopy, args.euler_step_size, args.euler_max_tries,
|
||||
args.newton_max_iter, args.newton_convergence_threshold, args.sigma)
|
||||
|
||||
num_frames = 0
|
||||
|
||||
bit_errors = 0
|
||||
frame_errors = 0
|
||||
decoding_failures = 0
|
||||
|
||||
homotopy = homotopy_generator.HomotopyGenerator(H)
|
||||
tracker = path_tracker.PathTracker(homotopy, args.euler_step_size, args.euler_max_tries,
|
||||
args.newton_max_iter, args.newton_convergence_threshold, args.sigma)
|
||||
|
||||
for _ in tqdm(range(args.max_frames)):
|
||||
Eb_N0_lin = 10**(Eb_N0 / 10)
|
||||
N0 = 1 / (2 * k / n * Eb_N0_lin)
|
||||
y = np.zeros(n) + np.sqrt(N0) * np.random.normal(size=n)
|
||||
|
||||
homotopy.update_received(y)
|
||||
|
||||
x_hat = decode(tracker, y, H, args)
|
||||
|
||||
if np.any(np.mod(H @ x_hat, 2)):
|
||||
tracker.set_sigma(-1 * args.sigma)
|
||||
x_hat = decode(tracker, y, H, args)
|
||||
tracker.set_sigma(args.sigma)
|
||||
|
||||
if np.any(np.mod(H @ x_hat, 2)):
|
||||
decoding_failures += 1
|
||||
|
||||
bit_errors += np.sum(x_hat != np.zeros(n))
|
||||
frame_errors += np.any(x_hat != np.zeros(n))
|
||||
|
||||
if np.any(np.mod(H @ x_hat, 2)):
|
||||
decoding_failures += 1
|
||||
|
||||
num_frames += 1
|
||||
|
||||
if frame_errors >= args.target_frame_errors:
|
||||
@@ -160,8 +160,10 @@ def main():
|
||||
FERs, BERs, DFRs, frame_errors_list = simulate_error_rates(
|
||||
H, SNRs, simulation_args)
|
||||
|
||||
df = pd.DataFrame({"SNR": SNRs, "FER": FERs, "BER": BERs, "DFR": DFRs, "frame_errors": frame_errors_list})
|
||||
df = pd.DataFrame({"SNR": SNRs, "FER": FERs, "BER": BERs,
|
||||
"DFR": DFRs, "frame_errors": frame_errors_list})
|
||||
print(df)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -30,7 +30,7 @@ class ToyHomotopy:
|
||||
[t]]
|
||||
"""
|
||||
@staticmethod
|
||||
def evaluate_H(y: np.ndarray) -> np.ndarray:
|
||||
def H(y: np.ndarray) -> np.ndarray:
|
||||
"""Evaluate H at y."""
|
||||
x1 = y[0]
|
||||
x2 = y[1]
|
||||
@@ -43,7 +43,7 @@ class ToyHomotopy:
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def evaluate_DH(y: np.ndarray) -> np.ndarray:
|
||||
def DH(y: np.ndarray) -> np.ndarray:
|
||||
"""Evaluate Jacobian of H at y."""
|
||||
x1 = y[0]
|
||||
x2 = y[1]
|
||||
|
||||
Reference in New Issue
Block a user