https://github.com/jancervenka/genalg
Solver for traveling salesman problem
https://github.com/jancervenka/genalg
genetic-algorithm numpy python
Last synced: about 1 year ago
JSON representation
Solver for traveling salesman problem
- Host: GitHub
- URL: https://github.com/jancervenka/genalg
- Owner: jancervenka
- Created: 2016-11-13T05:55:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T21:58:10.000Z (almost 3 years ago)
- Last Synced: 2025-02-16T03:45:02.563Z (over 1 year ago)
- Topics: genetic-algorithm, numpy, python
- Language: Python
- Homepage:
- Size: 1.46 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GENALG
Example of a genetic algorithm solution to the traveling salesman problem.
You can install the package using `setup.py` as:
```bash
python setup.py install
```
## Example
```python
from genalg.algorithm import GeneticAlgorithm, Problem
cities = [(20, 30), (50, 10), (21, 22), (35, 40),
(10, 15), (91, 21), (25, 22), (55, 11),
(12, 12), (13, 55), (51, 69), (52, 25),
(13, 14), (51, 85), (11, 99), (82, 44),
(33, 24), (93, 22), (85, 29), (21, 19)]
problem = Problem(cities=cities)
ga = GeneticAlgorithm(problem=problem)
solution = ga.compute(n_generation=50)
print(solution.fitness)
print(solution.path)
```

