Tsukihjy's picture
download
raw
6.01 kB
import matplotlib.pyplot as plt
import numpy as np
# Data from optimization_summary.txt
turns = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 20, 21, 23, 24, 25, 26, 30, 31, 35, 40, 47, 48, 54, 55, 61, 67, 76, 103, 148, 176, 188, 250, 281, 362, 364, 485, 566, 726, 1007]
counts = [950, 118, 65, 22, 19, 10, 13, 12, 7, 7, 5, 6, 2, 3, 3, 2, 1, 1, 2, 3, 1, 2, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
avg_improvements = [28.2802, 0.0603, 0.0456, 0.0425, 0.0467, 0.0445, 0.0273, 0.0000, 0.0000, 0.0238, 0.0000, 0.0000, 0.0175, 0.0188, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000]
# Set counts to 0 where avg_improvements is 0
counts_adjusted = [c if imp > 0 else 0 for c, imp in zip(counts, avg_improvements)]
# Create figure and axis
fig, ax1 = plt.subplots(figsize=(28, 14))
# Plot problem counts on left y-axis
color1 = '#2E86AB'
ax1.set_xlabel('Turn', fontsize=48)
ax1.set_ylabel('Number of Problems Modified', color=color1, fontsize=48)
line1 = ax1.plot(turns[:20], counts[:20], 'o-', color=color1, linewidth=2, markersize=6, markeredgecolor='black', label='Problems Modified')
ax1.tick_params(axis='y', labelcolor=color1)
ax1.set_ylim(bottom=0)
ax1.grid(True, alpha=0.3)
# Create second y-axis for average improvements
ax2 = ax1.twinx()
color2 = '#D62828'
ax2.set_ylabel('Average Improvement', color=color2, fontsize=24)
line2 = ax2.plot(turns[:20], avg_improvements[:20], 's-', color=color2, linewidth=2, markersize=6, label='Avg Improvement')
ax2.tick_params(axis='y', labelcolor=color2)
ax2.set_ylim(bottom=0)
# Set x-axis to log scale for better visualization of the long tail
ax1.set_xscale('log')
ax1.set_xlim(left=0.9, right=25)
# Add title
plt.title('Optimization Progress: Problems Modified and Average Improvement per Turn', fontsize=14, pad=20)
# Combine legends from both axes
lines = line1 + line2
labels = [l.get_label() for l in lines]
ax1.legend(lines, labels, loc='upper right', fontsize=11)
# Adjust layout
plt.tight_layout()
# Save figure
plt.savefig('optimization_turns_dual_axis.png', dpi=150, bbox_inches='tight')
plt.show()
print("Plot saved as optimization_turns_dual_axis.png")
# Create a second version with broken y-axis for better visualization
from mpl_toolkits.axes_grid1 import make_axes_locatable
# Create figure with two subplots stacked vertically (broken axis effect)
fig2, (ax_top, ax_bottom) = plt.subplots(2, 1, figsize=(14, 8), sharex=True,
gridspec_kw={'height_ratios': [1, 2], 'hspace': 0.05})
# Top subplot for high values (Turn 1)
ax_top.bar(range(len(turns)), counts_adjusted, color=color1, alpha=0.7)
ax_top.set_ylim(800, 1000)
ax_top.spines['bottom'].set_visible(False)
ax_top.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
ax_top.tick_params(axis='y', labelcolor=color1)
ax_top.set_ylabel('Number of Problems Modified', color=color1, fontsize=12)
ax_top.grid(True, alpha=0.3, axis='y')
# Bottom subplot for low values (all other turns)
ax_bottom.bar(range(len(turns)), counts_adjusted, color=color1, alpha=0.7, label='Problems Modified')
ax_bottom.set_ylim(0, 150)
ax_bottom.spines['top'].set_visible(False)
ax_bottom.tick_params(axis='y', labelcolor=color1)
# Remove duplicate label - only set it once
ax_bottom.set_xlabel('Turn', fontsize=12)
ax_bottom.grid(True, alpha=0.3, axis='y')
# Add diagonal lines to indicate broken axis
d = .015 # size of diagonal lines
kwargs = dict(transform=ax_top.transAxes, color='k', clip_on=False, linewidth=1)
ax_top.plot((-d, +d), (-d, +d), **kwargs) # top-left diagonal
ax_top.plot((1 - d, 1 + d), (-d, +d), **kwargs) # top-right diagonal
kwargs.update(transform=ax_bottom.transAxes)
ax_bottom.plot((-d, +d), (1 - d, 1 + d), **kwargs) # bottom-left diagonal
ax_bottom.plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs) # bottom-right diagonal
# Create twin axes for average improvement
ax_top2 = ax_top.twinx()
ax_top2.plot(range(len(turns)), avg_improvements, 'o-', color=color2, linewidth=2, markersize=5)
ax_top2.set_ylim(25, 30)
ax_top2.tick_params(axis='y', labelcolor=color2)
ax_top2.spines['bottom'].set_visible(False)
ax_top2.set_ylabel('Average Improvement', color=color2, fontsize=12)
ax_bottom2 = ax_bottom.twinx()
ax_bottom2.plot(range(len(turns)), avg_improvements, 'o-', color=color2, linewidth=2, markersize=5, label='Avg Improvement')
ax_bottom2.set_ylim(0, 0.1)
ax_bottom2.tick_params(axis='y', labelcolor=color2)
ax_bottom2.spines['top'].set_visible(False)
# Custom x-axis labels (show only selected turns)
selected_indices = [0, 1, 2, 3, 4, 5, 6, 10, 15, 20, 25, 30, 35, 40, 44]
ax_bottom.set_xticks(selected_indices)
ax_bottom.set_xticklabels([str(turns[i]) for i in selected_indices], rotation=45)
# Remove title - no title as requested
# Add vertical line to separate main optimization from long tail
for ax in [ax_top, ax_bottom]:
ax.axvline(x=7, color='gray', linestyle='--', alpha=0.5)
# ax_bottom.text(7.5, 140, 'Convergence point', rotation=90, va='top', fontsize=10, color='gray')
# Combined legend - moved to upper right of top subplot
lines1, labels1 = ax_bottom.get_legend_handles_labels()
lines2, labels2 = ax_bottom2.get_legend_handles_labels()
ax_top.legend(lines1 + lines2, labels1 + labels2, loc='upper right', fontsize=11)
# Save figure
plt.savefig('optimization_turns_complete.png', dpi=150, bbox_inches='tight')
plt.show()
print("Complete plot saved as optimization_turns_complete.png")
# Print statistics
print(f"\nKey Statistics:")
print(f"Turn 1 contributed {counts[0]/sum(counts)*100:.1f}% of all optimizations")
print(f"First 7 turns contributed {sum(counts[:7])/sum(counts)*100:.1f}% of all optimizations")
print(f"Average improvement in Turn 1: {avg_improvements[0]:.4f}")
print(f"Total problems optimized: {sum(counts)}")

Xet Storage Details

Size:
6.01 kB
·
Xet hash:
501a3a993405d75349ecd48b056e02296a05476c075e0057998c15c11d09da0a

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.