Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@wemap/salesman.js
Advanced tools
Readme
See: demo
Author: Ophir LOJKINE
Author: Thibaud MICHEL
salesman npm module Modified by Wemap (thibaud@getwemap.com) to add ts
Good heuristic for the traveling salesman problem using simulated annealing.
Array.<number>
Kind: inner class of salesman
Represents a point in two dimensions. Used as the input for solve
.
Param | Type | Description |
---|---|---|
x | number | abscissa |
y | number | ordinate |
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. Smaller values (0.9) work faster but give poorer solutions, whereas values closer to 1 (0.99999) work slower, but give better solutions. |
[callback] | function | An optional callback to be called after each iteration. | |
[callback] | function | euclidean | An optional argument to specify how distances are calculated. The function takes two Point objects as arguments and returns a number for distance. Defaults to simple Euclidean distance calculation. |
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.
FAQs
Solves the traveling salesman problem using simulated annealing.
The npm package @wemap/salesman.js receives a total of 7 weekly downloads. As such, @wemap/salesman.js popularity was classified as not popular.
We found that @wemap/salesman.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.