Skip to content

sam131725/MYMLLIBRARY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyML Reinforcement Learning Library

C++ Standard License: MIT

MyML is a lightweight, original C++ library designed for Reinforcement Learning (RL) research and educational purposes. Built from scratch with zero external dependencies, it provides a clean, abstract interface for environments and efficient algorithm implementations like Q-Learning.

🚀 Features

  • Standardized RL API: Clean Environment and Agent abstractions.
  • Q-Learning Implementation: High-performance implementation of the Bellman Equation.
  • Modular Environments: Includes a GridWorld task for testing agent convergence.
  • Convergence Tracking: Automatic export of training rewards and metrics to CSV.
  • Built-in CLI CLI Visualization: Real-time terminal rendering of agent behavior.

🏗️ Architecture

MyML follows the classical RL ecosystem structure:

  1. Types: Shared data structures for transitions (Step).
  2. Environment Interface: Abstract base class requiring reset() and step().
  3. Agent Implementation: Concrete agents (like QLearner) that interoperate with any Environment.

🛠️ Installation & Build

Prerequisites

  • C++17 Compatible Compiler (GCC 7+, Clang 5+, or MSVC 2019+)
  • CMake 3.10+

Build Instructions

mkdir build && cd build
# For Release (Industry Standard Optimization)
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release

🧪 Running Tests

MyML comes with a comprehensive testing suite to ensure "Physics" integrity and mathematical convergence.

# Run Unit Tests (Physics & Bounds checking)
./Release/myml_tests.exe

# Run Integration Demo (Training & Visualization)
./Release/myml_rl_demo.exe

📈 Example Usage

#include "myml/rl/QLearner.hpp"
#include "myml/rl/GridWorld.hpp"

myml::rl::GridWorld env(5);
myml::rl::QLearner agent(env.get_num_states(), env.get_num_actions());

// Training loop
for (int i = 0; i < 500; ++i) {
    int state = env.reset();
    bool done = false;
    while (!done) {
        int action = agent.predict_action(state);
        auto step_res = env.step(action);
        agent.train(state, action, step_res.reward, step_res.next_state, step_res.done);
        state = step_res.next_state;
        done = step_res.done;
    }
}

About

REINFORCEMENT LEARNING made from scratch using c++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors