npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@neural-trader/example-logistics-optimization

v1.0.0

Published

Self-learning vehicle routing optimization with multi-agent swarm coordination

Readme

@neural-trader/example-logistics-optimization

Self-learning vehicle routing optimization with multi-agent swarm coordination.

Features

  • Vehicle Routing Problem (VRP) with time windows
  • Multi-Agent Swarm Optimization using 10+ agents in parallel
  • Multiple Algorithms: Genetic Algorithm, Simulated Annealing, Ant Colony Optimization
  • Self-Learning System with AgentDB for pattern storage
  • Traffic Pattern Learning from historical routes
  • OpenRouter Integration for constraint reasoning
  • Real-Time Route Re-optimization
  • Sublinear Solver for large-scale instances

Installation

npm install @neural-trader/example-logistics-optimization

Quick Start

import {
  LogisticsOptimizer,
  createSampleData,
  SwarmConfig
} from '@neural-trader/example-logistics-optimization';

// Create sample problem
const { customers, vehicles } = createSampleData(50, 5);

// Configure swarm
const swarmConfig: SwarmConfig = {
  numAgents: 10,
  topology: 'mesh',
  communicationStrategy: 'best-solution',
  convergenceCriteria: {
    maxIterations: 100
  }
};

// Optimize with swarm
const optimizer = new LogisticsOptimizer(
  customers,
  vehicles,
  true, // use swarm
  swarmConfig
);

const solution = await optimizer.optimize();
console.log(`Best fitness: ${solution.fitness}`);
console.log(`Total cost: $${solution.totalCost}`);
console.log(`Routes: ${solution.routes.length}`);

Swarm Coordination

The package uses agentic-flow for multi-agent coordination, allowing 10+ agents to explore different optimization strategies simultaneously:

// 12 agents with different algorithms
const swarmConfig: SwarmConfig = {
  numAgents: 12,
  topology: 'mesh',
  communicationStrategy: 'best-solution',
  convergenceCriteria: {
    maxIterations: 200,
    noImprovementSteps: 30
  }
};

const coordinator = new SwarmCoordinator(
  swarmConfig,
  customers,
  vehicles
);

// Monitor progress
const monitorInterval = setInterval(() => {
  const status = coordinator.getStatus();
  console.log(`Iteration ${status.iteration}, Best: ${status.globalBestFitness}`);
}, 1000);

const solution = await coordinator.optimize();
clearInterval(monitorInterval);

Self-Learning

The system learns from every optimization run:

// Get learning statistics
const stats = optimizer.getStatistics();
console.log(`Total episodes: ${stats.totalEpisodes}`);
console.log(`Improvement rate: ${stats.improvementRate}%`);
console.log(`Traffic patterns learned: ${stats.trafficPatternsLearned}`);

// Export learned patterns
const patterns = optimizer.exportPatterns();
saveToFile('patterns.json', patterns);

// Import patterns in new session
const savedPatterns = loadFromFile('patterns.json');
optimizer.importPatterns(savedPatterns);

Algorithms

Genetic Algorithm

Evolves solutions through selection, crossover, and mutation:

const solution = await optimizer.optimize('genetic');

Simulated Annealing

Explores solution space with temperature-based acceptance:

const solution = await optimizer.optimize('simulated-annealing');

Ant Colony Optimization

Uses pheromone trails to guide solution construction:

const solution = await optimizer.optimize('ant-colony');

AI-Powered Recommendations

Use OpenRouter for intelligent constraint analysis:

// Set API key
process.env.OPENROUTER_API_KEY = 'your-key-here';

// Get recommendations
const recommendations = await optimizer.getRecommendations(solution);
console.log(recommendations);

Examples

Basic Usage

npm run build
node dist/../examples/basic-usage.js

12-Agent Swarm Coordination

node dist/../examples/swarm-coordination.js

Testing

npm test                 # Run tests
npm run test:watch      # Watch mode
npm run test:coverage   # Coverage report

API Reference

LogisticsOptimizer

Main optimization system combining routing, swarm coordination, and learning.

constructor(
  customers: Customer[],
  vehicles: Vehicle[],
  useSwarm: boolean = true,
  swarmConfig?: SwarmConfig
)

Methods:

  • optimize(algorithm?): Run optimization
  • getRecommendations(solution): Get AI recommendations
  • getSimilarSolutions(topK): Retrieve similar past solutions
  • getStatistics(): Get learning statistics
  • getSwarmStatus(): Get swarm status
  • exportPatterns(): Export learned patterns
  • importPatterns(data): Import learned patterns

SwarmCoordinator

Multi-agent swarm coordination for parallel optimization.

constructor(
  config: SwarmConfig,
  customers: Customer[],
  vehicles: Vehicle[],
  openRouterApiKey?: string
)

Methods:

  • optimize(): Run swarm optimization
  • getStatus(): Get current status
  • getAgents(): Get agent details
  • reasonAboutConstraints(solution): Get LLM analysis

SelfLearningSystem

Adaptive learning system with memory and pattern recognition.

constructor(learningRate: number = 0.1)

Methods:

  • learnFromSolution(solution, customers, metrics): Learn from episode
  • retrieveSimilarSolutions(numCustomers, numVehicles, topK): Find similar past solutions
  • getTrafficPrediction(from, to, time, day): Get traffic prediction
  • getStatistics(): Get learning stats
  • exportPatterns(): Export learned patterns
  • importPatterns(data): Import patterns
  • reset(): Reset learning state

Performance

With 50 customers and 5 vehicles:

  • Single-agent: ~2-3 seconds
  • 10-agent swarm: ~1-1.5 seconds (2x speedup)
  • Solution quality: 15-30% better with swarm

License

MIT

Contributing

Contributions welcome! Please read our contributing guidelines first.