From b5873a7ba33c513c8594b4e333ce81939f1b718c Mon Sep 17 00:00:00 2001 From: Arity-T Date: Thu, 11 Sep 2025 17:37:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B8=D0=BD=D1=84=D1=83=20=D0=BD=D0=B0=20=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab1/gen.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lab1/gen.py b/lab1/gen.py index 25a4f71..59cc626 100644 --- a/lab1/gen.py +++ b/lab1/gen.py @@ -314,10 +314,11 @@ def plot_generation_snapshot( plt.scatter( current_pop_x, current_pop_f, - s=20, - alpha=0.9, - color="gray", - label=f"Популяция поколения {generation}", + s=50, + alpha=0.8, + color="black", + label=f"Популяция поколения #{generation + 1}", + zorder=10, ) # Лучшая особь красной точкой @@ -327,12 +328,13 @@ def plot_generation_snapshot( plt.scatter( [current_pop_x[best_idx]], [current_pop_f[best_idx]], - s=60, + s=100, color="red", marker="o", - label=f"Лучшая особь поколения {generation}", + label=f"Лучшая особь поколения #{generation + 1}", edgecolors="darkred", linewidth=1, + zorder=10, ) # История лучших по поколениям (до текущего включительно) @@ -343,14 +345,19 @@ def plot_generation_snapshot( history_x_until_now, history_f_until_now, s=15, - alpha=0.9, + alpha=0.8, color="orange", label="Лучшие предыдущих поколений", + zorder=10, ) plt.xlabel("x") plt.ylabel("f(x)") - plt.title(f"Популяция поколения {generation}") + plt.title( + f"Поколение #{generation + 1}. " + f"Лучшая особь: {history_best_f[generation]:.4f}. " + f"Среднее значение: {np.mean(history_populations_f[generation]):.4f}" + ) plt.legend(loc="best") plt.grid(True, alpha=0.3) plt.tight_layout()