forked from dcmox/tspwc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.ts
17 lines (14 loc) · 799 Bytes
/
usage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { ITspResult, ITspStop } from '../lib/interfaces'
import { solve } from '../tspwc'
import { stops } from './test-data'
const initialTime: Date = stops[0].startTime || new Date()
const description: string = 'Getting paths for 8 stops from ' + stops[0].id + ' to ' + stops[stops.length - 1].id
console.time(description)
const solutions = solve(stops, initialTime, 100)
console.timeEnd(description)
console.log('Number of solutions found', solutions.length)
console.log('Solution length', (solutions[0] as ITspResult).path.length)
console.log('Shortest valid trip', (solutions[0] as ITspResult).cost)
console.log('Longest valid trip', (solutions[solutions.length - 1] as ITspResult).cost)
console.log('Path', (solutions[0] as ITspResult).path)
console.log(JSON.stringify(solutions, null, 2))