From bd5b9c012a3a91ef9260ca89596b1e13d0c5bb4f Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 19 May 2022 03:48:00 +0400 Subject: feat: iterate until error is small enough --- src/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main.py') diff --git a/src/main.py b/src/main.py index 01f0c19..551595e 100644 --- a/src/main.py +++ b/src/main.py @@ -1,11 +1,16 @@ from simple import SIMPLE problem = SIMPLE((1, 2), (0.7, 0.5), 0.02, 120) - problem.prep() -for i in range(3000): - print(f'Iteration {i}') +error = 1 +iteration = 0 +while error > 10 ** -7: + iteration += 1 problem.iterate() - if i % 5 == 0 or i == 1: + error = problem.avg_error() + print(f'Iteration {iteration}') + print(f'Avg error: {error}') + + if iteration % 5 == 0 or iteration == 1: problem.plot(True, 2) -- cgit v1.2.3