8000 GitHub - bywo/salesman.js: Solves the traveling salesman problem using simulated annealing.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bywo/salesman.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

salesman

See: demo
Author: Ophir LOJKINE salesman npm module

Good heuristic for the traveling salesman problem using simulated annealing.

salesman~Point

Kind: inner class of salesman

new Point(x, y)

Represents a point in two dimensions.

Param Type Description
x Number abscissa
y Number ordinate

salesman~solve(points, [temp_coeff], [callback=]) ⇒ Array.<Number>

Solves the following problem: Given a list of points and the distances between each pair of points, what is the shortest possible route that visits each point exactly once and returns to the origin point?

Kind: inner method of salesman
Returns: Array.<Number> - An array of indexes in the original array. Indicates in which order the different points are visited.

Param Type Default Description
points Array.<Point> The points that the path will have to visit.
[temp_coeff] Number 0.999 changes the convergence speed of the algorithm: the closer to 1, the slower the algorithm and the better the solutions.
[callback=] function An optional callback to be called after each iteration.

Example

var points = [
      new salesman.Point(2,3)
      //other points
    ];
var solution = salesman.solve(points);
var ordered_points = solution.map(i => points[i]);
// ordered_points now contains the points, in the order they ought to be visited.

About

Solves the traveling salesman problem using simulated annealing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
0