๐ง Local AI memory managementJune 9, 2026โ
Tests passing
Memory Decay Simulation Tool
A CLI tool to simulate and visualize memory decay in AI systems. Developers can test different decay strategies, analyze how memory diminishes over time, and optimize configurations for their AI workflows.
What It Does
- Simulate exponential and linear memory decay.
- Visualize memory decay using matplotlib.
- Save the decay plot as an image file.
Installation
1. Clone the repository:
git clone <repository_url>
cd memory_decay_simulator2. Install the required dependencies:
pip install -r requirements.txtUsage
Run the CLI tool with the following arguments:
python memory_decay_simulator.py --strategy <strategy> --rate <rate> --duration <duration>Arguments
--strategy: Decay strategy (exponentialorlinear).--rate: Decay rate (positive float).--duration: Duration of the simulation (positive integer).
Example
Simulate exponential decay with a rate of 0.05 over 100 time units:
python memory_decay_simulator.py --strategy exponential --rate 0.05 --duration 100Source Code
import argparse
import numpy as np
import matplotlib.pyplot as plt
def exponential_decay(rate, duration):
"""Simulate exponential memory decay."""
time = np.arange(0, duration + 1)
memory = np.exp(-rate * time)
return time, memory
def linear_decay(rate, duration):
"""Simulate linear memory decay."""
time = np.arange(0, duration + 1)
memory = np.maximum(1 - rate * time, 0)
return time, memory
def simulate_decay(strategy, rate, duration):
"""Simulate memory decay based on the given strategy."""
if strategy == "exponential":
return exponential_decay(rate, duration)
elif strategy == "linear":
return linear_decay(rate, duration)
else:
raise ValueError("Unsupported strategy. Choose 'exponential' or 'linear'.")
def plot_decay(time, memory, strategy, rate, duration):
"""Plot memory decay over time."""
plt.figure(figsize=(8, 5))
plt.plot(time, memory, label=f"{strategy.capitalize()} Decay (rate={rate})")
plt.title("Memory Decay Simulation")
plt.xlabel("Time")
plt.ylabel("Memory Retention")
plt.ylim(0, 1.1)
plt.grid(True)
plt.legend()
plt.savefig("memory_decay_simulation.png")
plt.show()
def main():
parser = argparse.ArgumentParser(
description="Memory Decay Simulation Tool"
)
parser.add_argument(
"--strategy",
type=str,
choices=["exponential", "linear"],
required=True,
help="Decay strategy: 'exponential' or 'linear'"
)
parser.add_argument(
"--rate",
type=float,
required=True,
help="Decay rate (positive float)"
)
parser.add_argument(
"--duration",
type=int,
required=True,
help="Duration of the simulation (positive integer)"
)
args = parser.parse_args()
if args.rate <= 0 or args.duration <= 0:
print("Error: Rate and duration must be positive values.")
return
try:
time, memory = simulate_decay(args.strategy, args.rate, args.duration)
plot_decay(time, memory, args.strategy, args.rate, args.duration)
except ValueError as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- memory_decay_simulator
- Category
- Local AI memory management
- Generated
- June 9, 2026
- Tests
- Passing โ
- Fix Loops
- 2
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-06-09/memory_decay_simulator cd generated_tools/2026-06-09/memory_decay_simulator pip install -r requirements.txt 2>/dev/null || true python memory_decay_simulator.py