MCPcopy Index your code
hub / github.com/Valdecy/pyCombinatorial

github.com/Valdecy/pyCombinatorial @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
802 symbols 2,009 edges 146 files 21 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pyCombinatorial

New to Python or prefer a graphical interface? The pyCombinatorial Web App lets you run your analysis in clicks, not lines of code.

import pyCombinatorial

# Start the web service using:
pyCombinatorial.web_app()

# Terminate the web service using:
pyCombinatorial.web_stop()

Lab

This Google Colab Demo is intended for quick demos only. For the best experience, run the Web UI locally or open it directly in a full browser.

Introduction

pyCombinatorial is a Python-based library designed to tackle the classic Traveling Salesman Problem (TSP) through a diverse set of Exact Algorithms, Heuristics, Metaheuristics, and Reinforcement Learning. It brings together well-established and cutting-edge methodologies, offering end users a flexible toolkit to generate high-quality solutions for TSP instances of varying sizes and complexities.

Techniques: 2-opt; 2.5-opt; 3-opt; 4-opt; 5-opt; Or-opt; 2-opt Stochastic; 2.5-opt Stochastic; 3-opt Stochastic; 4-opt Stochastic; 5-opt Stochastic; Ant Colony Optimization; Adaptive Large Neighborhood Search; Bellman-Held-Karp Exact Algorithm; Bitonic Tour; Branch & Bound; BRKGA (Biased Random Key Genetic Algorithm); Brute Force; Cheapest Insertion; Christofides Algorithm; Clarke & Wright (Savings Heuristic); Concave Hull Algorithm; Convex Hull Algorithm; Elastic Net; Extremal Optimization; Farthest Insertion; FRNN (Fixed Radius Near Neighbor); Genetic Algorithm; GA-EAX (Genetic Algorithm with Edge Assembly Crossover); GRASP (Greedy Randomized Adaptive Search Procedure); Greedy Karp-Steele Patching; Guided Search; Hopfield Network; HGS (Hybrid Genetic Search); Iterated Search; Karp-Steele Patching; Large Neighborhood Search; LKH (Lin-Kernighan-Helsgaun); Multifragment Heuristic; Nearest Insertion; Nearest Neighbour; POPMUSIC (Partial OPtimization Metaheuristic Under Special Intensification Conditions); Random Insertion; Random Tour; Randomized Spectral Seriation; RL Q-Learning; RL Double Q-Learning; RL S.A.R.S.A (State Action Reward State Action); Ruin & Recreate; Scatter Search; Simulated Annealing; SOM (Self Organizing Maps); Space Filling Curve (Hilbert); Space Filling Curve (Morton); Space Filling Curve (Sierpinski); Spectral Seriation Initializer; Stochastic Hill Climbing; Sweep; Tabu Search; Truncated Branch & Bound; Twice-Around the Tree Algorithm (Double Tree Algorithm); Variable Neighborhood Search; Zero Suffix Method.

Usage

  1. Install
pip install pycombinatorial
  1. Import


# Required Libraries
import pandas as pd

# GA
from pyCombinatorial.algorithm import genetic_algorithm
from pyCombinatorial.utils import graphs, util

# Loading Coordinates # Berlin 52 (Minimum Distance = 7544.3659)
coordinates = pd.read_csv('https://bit.ly/3Oyn3hN', sep = '\t') 
coordinates = coordinates.values

# Obtaining the Distance Matrix
distance_matrix = util.build_distance_matrix(coordinates)

# GA - Parameters
parameters = {
            'population_size': 15,
            'elite': 1,
            'mutation_rate': 0.1,
            'mutation_search': 8,
            'generations': 1000,
            'verbose': True
             }

# GA - Algorithm
route, distance = genetic_algorithm(distance_matrix, **parameters)

# Plot Locations and Tour
graphs.plot_tour(coordinates, city_tour = route, view = 'browser', size = 10)
print('Total Distance: ', round(distance, 2))

  1. Try it in Colab

3.1 Lat Long Datasets

3.2 Algorithms

Core symbols most depended-on inside this repo

distanceCalc
called by 114
pyCombinatorial/web/js/core/distance.js
$
called by 39
pyCombinatorial/web/js/main.js
mulberry32
called by 21
pyCombinatorial/web/js/algorithms/_shared.js
idxOf
called by 20
pyCombinatorial/web/js/algorithms/eo.js
_flip
called by 17
pyCombinatorial/algorithm/popm.py
seedFunction
called by 17
pyCombinatorial/web/js/core/seed.js
flip
called by 17
pyCombinatorial/web/js/algorithms/popm.js
openToClosed
called by 17
pyCombinatorial/web/js/algorithms/lkh.js

Shape

Function 742
Method 50
Class 10

Languages

Python55%
TypeScript45%

Modules by API surface

pyCombinatorial/algorithm/lkh.py57 symbols
pyCombinatorial/web/js/main.js29 symbols
pyCombinatorial/web/js/algorithms/ga_eax.js28 symbols
pyCombinatorial/algorithm/ga_eax.py28 symbols
pyCombinatorial/web/js/algorithms/lkh.js26 symbols
pyCombinatorial/web/js/algorithms/popm.js24 symbols
pyCombinatorial/algorithm/hgs.py23 symbols
pyCombinatorial/web/js/algorithms/hgs.js22 symbols
pyCombinatorial/web/js/core/renderer.js20 symbols
pyCombinatorial/web/js/algorithms/_shared.js19 symbols
pyCombinatorial/algorithm/popm.py19 symbols
pyCombinatorial/web/js/core/stepper.js15 symbols

For agents

$ claude mcp add pyCombinatorial \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact