https://github.com/dcmox/tspwc
Traveling Salesman Problem - With Conditions
https://github.com/dcmox/tspwc
javascript maps traveling-salesman tsp tsp-tw tspwc typescript
Last synced: 6 months ago
JSON representation
Traveling Salesman Problem - With Conditions
- Host: GitHub
- URL: https://github.com/dcmox/tspwc
- Owner: dcmox
- License: gpl-3.0
- Created: 2019-12-31T15:29:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-21T22:46:46.000Z (over 1 year ago)
- Last Synced: 2025-03-27T16:50:25.546Z (7 months ago)
- Topics: javascript, maps, traveling-salesman, tsp, tsp-tw, tspwc, typescript
- Language: JavaScript
- Size: 50.8 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Traveling Salesman Problem - With Conditions
Whether you need to find the optimal route regardless of conditions or you have conditions based on time windows and load capacity, tsp-wc will help you find the shortest route.
## Sample Usage
See the [sample file in TypeScript](tests/usage.ts) to see how it can be used in your Node.js projects. The core function (solve) is in [tspwc.ts](tspwc.ts) and takes the following parameters:```
stops: ITspStop (required)
initialTime: Date (optional)
initialLoad: number (optional) - initial load capacity, generally set to 100
ignoreConditions: boolean (optional) - this will ignore conditions passed into stops
initialPath: [0] (optional, not recommended to change)
```ITspStop is defined as follows:
```typescript
export interface ITspStop {
id: string,
arriveBetween?: Date[],
arriveAfter?: Date,
arriveBy?: Date,
load?: number,
times: number[],
startTime?: Date
}
```### HTML
See [tests/demo.html](tests/demo.html) to learn more about how to incorporate this into your project via HTML and JS or tests/usage.ts for an example on how to tspwc with NodeJS and TypeScript. We have included a browser-friendly version of tspwc that you can [find here](tspwc-browser.js). Please note that you will need your own Google API key to test this with both Maps and Directions API enabled on your Google Account.## Available Scripts
In the project directory, you can run:
### `npm run build`
Builds [tspwc.ts] and [tests/usage.ts](tests/usage.ts) into JS files for usage. usage.ts is a demo of the script being used in Typescript while [tests/demo.html](tests/demo.html) provides a demonstration of usage within the browser.
### `npm run test-usage`
Runs the sample usage.js file which should output a log in your console.
## Learn More
You can learn more about [the developer here](https://www.linkedin.com/in/daniel-moxon/).