Artificial Algorithm Intelligence - Self-Adaptive Algorithm Selection & Universal Problem Solving
Project description
AAlgoI — Adaptive Algorithm Intelligence
Artificial Algorithm Intelligence — a self-adaptive system that automatically selects, executes, and learns from the best algorithm for any given problem. Combining reinforcement learning, a semantic knowledge graph, and a growing registry of 20+ algorithms across sorting, pathfinding, optimization, and machine learning domains.
Features
- Algorithm Selector — PPO-based RL agent picks the optimal algorithm from 20+ candidates based on problem type and data patterns
- Semantic Knowledge Graph — NetworkX-powered graph encoding relationships (Problem → Algorithm → Pattern → Constraint) that constrains RL choices and provides fallback alternatives
- Pre-Trained Model — 3-stage pipeline (supervised + RL curriculum + self-play) produces a 0.72 MB model with ~0.6 ms inference, validated on sorting, pathfinding, and domain routing (100% accuracy)
- Self-Learning — Every execution records feedback (quality, timing, success) to personalize the model via fine-tuning and bandit updates
- Algorithm Marketplace — Discover, register, benchmark, and share custom algorithms across instances
- Natural Language Interface —
question_parser.pyconverts English descriptions into structured problem specs - Federated Learning — Optional P2P or central-server mode for cross-instance knowledge sharing
- Rich CLI —
solve,benchmark,marketplace,ml,debug, and more - 226 Passing Tests — CI-verified test suite
Quick Start
# Install
pip install aalgoi
# Solve a problem by description
aalgoi solve "sort this list of numbers" --data 3,1,4,1,5,9,2,6,5,3,5
# Solve with explicit spec
aalgoi solve-spec --type sorting --data 5,2,8,1,9
Installation
From PyPI
pip install aalgoi
For optional features:
pip install aalgoi[rl] # Reinforcement learning (PyTorch)
pip install aalgoi[llm] # LLM integration (Ollama)
From Source
git clone https://github.com/RayAKaan/AAlgoI.git
cd AAlgoI
pip install -e .
Dependencies
Core: numpy, scikit-learn, networkx, chromadb, click, psutil RL (optional): torch>=2.0.0
Architecture
User Input (CLI)
│
▼
┌───────────────────┐
│ SmartSolver │ Natural language → ProblemSpec
│ question_parser │ Zero-shot + keyword fallback
└─────────┬─────────┘
│
▼
┌────────────────────────────────────────────┐
│ UniversalMetaController │
│ │
│ ┌──────────┐ ┌──────────────────┐ │
│ │ RL Agent │ │ Knowledge Graph │ │
│ │ (PPO) │ │ (read-only filter)│ │
│ │ 20-action│ │ Problem→Algorithm │ │
│ │ softmax │ │ Algorithm→Pattern │ │
│ └────┬─────┘ │ Algorithm→Complex │ │
│ │ └────────┬─────────┘ │
│ └─────────┬────────┘ │
│ ▼ │
│ Selected Algorithm │
│ │ │
│ ┌──────────────▼──────────────┐ │
│ │ Algorithm Registry │ │
│ │ 20 algorithms (growing) │ │
│ └──────────────┬──────────────┘ │
│ │ │
│ ┌──────────────▼──────────────┐ │
│ │ Execution + Feedback │ │
│ │ quality, timing, success │ │
│ └──────────────┬──────────────┘ │
│ │ │
│ ┌──────────────▼──────────────┐ │
│ │ Knowledge Base (ChromaDB) │ │
│ │ Pattern Store + Metrics │ │
│ └─────────────────────────────┘ │
└────────────────────────────────────────────┘
Pipeline Flow
- Input — CLI command or natural language
- Parsing —
SmartSolver/question_parserextract problem type and data - State Encoding — 200-dimensional vector: data stats + problem type one-hot + environment info
- RL Selection — PPO agent outputs action probabilities over 20 algorithms
- KG Validation — Knowledge graph constrains the action to semantically valid candidates
- Execution — Algorithm runs on the data; quality, timing, and success are recorded
- Feedback — Results update the bandit, knowledge base, and optionally fine-tune the RL model
Pre-Trained Model
AAlgoI ships with pretrained_v1.pt — a 3-stage pre-trained model:
| Stage | Iterations | Description |
|---|---|---|
| 1. Supervised Bootstrapping | 200,000 | Textbook rules via CrossEntropy on raw logits |
| 2. RL Curriculum (optional) | 100,000 | PPO refinement with curriculum-based difficulty |
| 3. Self-Play (optional) | — | Adversarial WorldModel (disabled by default) |
Guarantees
| Check | Requirement | Actual |
|---|---|---|
| Sorting Accuracy | 100% | 100% |
| Pathfinding Accuracy | 100% | 100% |
| Domain Routing | 100% | 100% |
| Inference Time | < 5 ms | ~0.6 ms |
| Model Size | < 10 MB | 0.72 MB |
Generate your own:
python training/pretrain_master.py
CLI Reference
| Command | Description |
|---|---|
aalgoi solve |
Solve a problem from natural language description |
aalgoi solve-spec |
Solve a structured problem (type, data, constraints) |
aalgoi explain |
Explain why a specific algorithm was chosen |
aalgoi stats |
Show performance statistics per algorithm |
aalgoi benchmark |
Run benchmarks across algorithms |
aalgoi marketplace list |
List registered algorithms |
aalgoi marketplace search |
Search algorithms by name/pattern |
aalgoi ml train-word2vec |
Train a Word2Vec model |
aalgoi ml similar-words |
Find similar words in a trained model |
aalgoi ml visualize-embeddings |
Visualize word embeddings |
aalgoi debug visualize |
Visualize internal state / decision boundaries |
Adding Algorithms
from pipeline import UniversalSolver
from algorithms.base import Algorithm
class MyCustomSort(Algorithm):
def process(self, data):
return sorted(data)
solver = UniversalSolver()
solver.registry["my_sort"] = MyCustomSort()
For persistent registration, add your algorithm to algorithms/ and register it in pipeline.py.
Training
# Pre-train the model
python training/pretrain_master.py
Tests
pytest tests/ -v
# 226 passed
Project Structure
AAlgoI/
├── algorithms/ # Algorithm implementations by domain
│ ├── sorting/ # quicksort, timsort, heapsort, etc.
│ ├── pathfinding/ # dijkstra, a_star, bfs_path
│ ├── optimization/ # greedy_knapsack, simulated_annealing
│ └── ml/ # word2vec, pca, tsne, semantic
├── core/ # Core engine
│ ├── rl/ # PPO agent, WorldModel, reward shaper
│ ├── meta_controller.py # Central orchestration
│ ├── knowledge_graph.py # Semantic relationship graph
│ ├── knowledge_base.py # Vector performance store
│ ├── pipeline_graph.py # Execution pipeline
│ └── problem_spec.py # Problem type system
├── interface/ # User interfaces
│ ├── cli.py # Click CLI
│ ├── cli_ml.py # ML subcommands
│ ├── cli_debug.py # Debug subcommands
│ └── nl_parser.py # Natural language parsing
├── training/ # Training pipelines
│ ├── pretrain_master.py # 3-stage pre-training
│ ├── self_play.py # Adversarial self-play
│ ├── curriculum.py # Difficulty scheduler
│ └── data_generator.py # Synthetic problem generator
├── tests/ # 226 test cases
├── checkpoints/ # Pretrained model files
└── pipeline.py # UniversalSolver entry point
License
MIT License — see LICENSE.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aalgoi-1.1.0.tar.gz.
File metadata
- Download URL: aalgoi-1.1.0.tar.gz
- Upload date:
- Size: 7.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6638628a5db46454403da75b39068e1feb105b734683d35b091a97054260e29
|
|
| MD5 |
d76e31470abad81442e9121e28e21ed8
|
|
| BLAKE2b-256 |
1cb03e6dd956076c5e0be2d374e8c7af23c2bcb2a0be96db0b4d1a4be64f0ea0
|
File details
Details for the file aalgoi-1.1.0-py3-none-any.whl.
File metadata
- Download URL: aalgoi-1.1.0-py3-none-any.whl
- Upload date:
- Size: 111.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25031acc32af38d01afeba953a4d5c94197bf1ee901cdb0aa75a829b26b391a1
|
|
| MD5 |
1f015aa0ee11b097c1ab36a9d5bf1e54
|
|
| BLAKE2b-256 |
6879805d9cb1869a846d463bda0e0d341627e302cd90d8cb09c0f8edb6fe5832
|