Skip to main content

Negative Weight Mapping - A Reinforcement Learning framework using persistent potential fields

Project description

NWM - Negative Weight Mapping

Apprendimento per Esclusione - Un framework che guida l'esplorazione e la stabilita utilizzando memorie persistenti di fallimento e successo.

Cos'e NWM?

Il Negative Weight Mapping trasforma l'esperienza passata in un Campo di Forza Potenziale. L'agente naviga lo spazio degli stati reagendo a:

  • Forze Attrattive - Successi passati che guidano verso azioni ottimali
  • Forze Repulsive - Fallimenti passati che allontanano da azioni pericolose

Caratteristiche Principali

Feature Descrizione
Dynamic Smart Lock Protegge automaticamente le memorie di alta qualita
Adaptive Exploration Riduce l'esplorazione quando trova strategie vincenti
Persistent Memory I centroidi evolvono con "stiffness" progressiva
Fear & Greed Evita le azioni pericolose prima di cercare il guadagno

Installazione

pip install nwm-rl

Oppure da sorgente:

git clone https://github.com/CastermustOfficial/NWM.git
cd NWM
pip install -e .

Quick Start

import gymnasium as gym
from nwm import NWM

# Crea ambiente e agente
env = gym.make("CartPole-v1")
agent = NWM(
    state_dim=env.observation_space.shape[0],
    num_actions=env.action_space.n
)

# Training loop
for episode in range(100):
    state, _ = env.reset()
    done = False
  
    while not done:
        action = agent.select_action(state)
        next_state, reward, terminated, truncated, _ = env.step(action)
        done = terminated or truncated
        agent.step(state, action, reward, next_state, done)
        state = next_state
  
    print(f"Episode {episode + 1}: Best = {agent.best_reward:.0f}")

API Reference

NWM

from nwm import NWM, NWMConfig

# Con configurazione personalizzata
config = NWMConfig(
    max_centroids=500,      # Massimo numero di centroidi
    warmup_episodes=50,     # Episodi di pura esplorazione
    exploration_rate=1.0,   # Tasso iniziale di esplorazione
    exploration_decay=0.99, # Decay dell'esplorazione
    min_exploration=0.05,   # Esplorazione minima
)

agent = NWM(state_dim=4, num_actions=2, config=config)

# Metodi principali
action = agent.select_action(state, training=True)
agent.step(state, action, reward, next_state, done)
stats = agent.get_stats()

# Save/Load
agent.save("agent.pkl")
agent = NWM.load("agent.pkl")

NWMConfig

Parametro Default Descrizione
max_centroids 500 Numero massimo di centroidi in memoria
warmup_episodes 50 Episodi di warmup prima del learning
exploration_rate 1.0 Tasso iniziale di esplorazione
exploration_decay 0.99 Fattore di decay
min_exploration 0.05 Esplorazione minima
merge_threshold 0.3 Soglia per il merge dei centroidi
distance_cutoff 2.5 Distanza massima di influenza

Struttura del Package

PYTHONLIB/
├── nwm/                    # Package principale
│   ├── agents/             # Implementazioni agenti
│   ├── core/               # Componenti core (centroid, potential_field)
│   └── utils/              # Utilities (config)
├── examples/               # Esempi di utilizzo
└── tests/                  # Test suite

Esempi

# Quick start
python examples/quickstart.py

# Training completo
python examples/cartpole_training.py --episodes 500

# Demo visuale
python examples/cartpole_training.py --demo

Versione: 1.0.1 Licenza: MIT Autore: CusterMustOfficial

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nwm_rl-1.0.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nwm_rl-1.0.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file nwm_rl-1.0.1.tar.gz.

File metadata

  • Download URL: nwm_rl-1.0.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nwm_rl-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7b0b56c86985a30a9c0f74c79b8f2992a8862ad1f7e769b12fb3aff4cc3ac09c
MD5 0f58d525ede85d25535045929855f670
BLAKE2b-256 faba33aae308db54923404dba3523a3cf5e51e85036a4fb5acff1b4c4957853e

See more details on using hashes here.

File details

Details for the file nwm_rl-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: nwm_rl-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nwm_rl-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4582796c37573a69496d09446ffadfb1dfe581a270e791bf4c05c9bee66a9e53
MD5 c82b1728318b807935669437e1542bc8
BLAKE2b-256 600ad2131a566baf6265edf4859be2b502e55bbcce73e54ceef1282c0b3b2316

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page