@iyulab/u-routing 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/node/u_routing.cjs +434 -0
- package/node/u_routing.d.cts +23 -0
- package/node/u_routing_bg.wasm +0 -0
- package/package.json +17 -4
- package/u_routing_bg.js +43 -43
- package/u_routing_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -202,6 +202,19 @@ Errors are returned as rejected promises — they never cause `RuntimeError: unr
|
|
|
202
202
|
}
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
## npm (WebAssembly)
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npm install @iyulab/u-routing
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The package resolves per environment via a conditional `exports` map:
|
|
212
|
+
|
|
213
|
+
| Environment | Entry |
|
|
214
|
+
|---|---|
|
|
215
|
+
| Bundlers (webpack, Vite, …) | ESM + WebAssembly ESM-integration (`default` condition) |
|
|
216
|
+
| Node.js — `require()`, ESM `import`, CJS TS runners (`tsx`, `ts-node`) | CJS glue loading the wasm from the filesystem (`node` condition) — no loader hooks or flags |
|
|
217
|
+
|
|
205
218
|
## Related
|
|
206
219
|
|
|
207
220
|
- [u-numflow](https://crates.io/crates/u-numflow) — Mathematical optimization primitives
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/* @ts-self-types="./u_routing.d.cts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Solve a capacitated VRP problem.
|
|
5
|
+
*
|
|
6
|
+
* # Arguments
|
|
7
|
+
* * `problem` — A native JS object matching the VRP input schema.
|
|
8
|
+
*
|
|
9
|
+
* # Supported methods
|
|
10
|
+
* - `"nn"` — Nearest Neighbor (default, fast)
|
|
11
|
+
* - `"savings"` — Clarke-Wright Savings
|
|
12
|
+
* - `"ga"` — Genetic Algorithm with Prins split + local search
|
|
13
|
+
* - `"alns"` — Adaptive Large Neighborhood Search + local search
|
|
14
|
+
*
|
|
15
|
+
* # Returns
|
|
16
|
+
* A JS object with `routes`, `total_distance`, `num_vehicles`,
|
|
17
|
+
* `method_used`, and `computation_time_ms`.
|
|
18
|
+
*
|
|
19
|
+
* # Errors
|
|
20
|
+
* Returns a `JsValue` string describing the error if input is invalid.
|
|
21
|
+
* @param {any} problem
|
|
22
|
+
* @returns {any}
|
|
23
|
+
*/
|
|
24
|
+
function solve_vrp(problem) {
|
|
25
|
+
const ret = wasm.solve_vrp(problem);
|
|
26
|
+
if (ret[2]) {
|
|
27
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
28
|
+
}
|
|
29
|
+
return takeFromExternrefTable0(ret[0]);
|
|
30
|
+
}
|
|
31
|
+
exports.solve_vrp = solve_vrp;
|
|
32
|
+
function __wbg_get_imports() {
|
|
33
|
+
const import0 = {
|
|
34
|
+
__proto__: null,
|
|
35
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
36
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
37
|
+
return ret;
|
|
38
|
+
},
|
|
39
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
40
|
+
const ret = String(arg1);
|
|
41
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
42
|
+
const len1 = WASM_VECTOR_LEN;
|
|
43
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
44
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
45
|
+
},
|
|
46
|
+
__wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
|
|
47
|
+
const v = arg1;
|
|
48
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
49
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
50
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
51
|
+
},
|
|
52
|
+
__wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
|
|
53
|
+
const v = arg0;
|
|
54
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
55
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
56
|
+
},
|
|
57
|
+
__wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
|
|
58
|
+
const ret = debugString(arg1);
|
|
59
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len1 = WASM_VECTOR_LEN;
|
|
61
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
62
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
63
|
+
},
|
|
64
|
+
__wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
|
|
65
|
+
const ret = arg0 in arg1;
|
|
66
|
+
return ret;
|
|
67
|
+
},
|
|
68
|
+
__wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
|
|
69
|
+
const ret = typeof(arg0) === 'bigint';
|
|
70
|
+
return ret;
|
|
71
|
+
},
|
|
72
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
73
|
+
const ret = typeof(arg0) === 'function';
|
|
74
|
+
return ret;
|
|
75
|
+
},
|
|
76
|
+
__wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
|
|
77
|
+
const val = arg0;
|
|
78
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
79
|
+
return ret;
|
|
80
|
+
},
|
|
81
|
+
__wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
|
|
82
|
+
const ret = arg0 === arg1;
|
|
83
|
+
return ret;
|
|
84
|
+
},
|
|
85
|
+
__wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
|
|
86
|
+
const ret = arg0 == arg1;
|
|
87
|
+
return ret;
|
|
88
|
+
},
|
|
89
|
+
__wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
|
|
90
|
+
const obj = arg1;
|
|
91
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
92
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
93
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
94
|
+
},
|
|
95
|
+
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
96
|
+
const obj = arg1;
|
|
97
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
98
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
99
|
+
var len1 = WASM_VECTOR_LEN;
|
|
100
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
101
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
102
|
+
},
|
|
103
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
104
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
105
|
+
},
|
|
106
|
+
__wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
|
|
107
|
+
const ret = arg0.call(arg1);
|
|
108
|
+
return ret;
|
|
109
|
+
}, arguments); },
|
|
110
|
+
__wbg_done_89b2b13e91a60321: function(arg0) {
|
|
111
|
+
const ret = arg0.done;
|
|
112
|
+
return ret;
|
|
113
|
+
},
|
|
114
|
+
__wbg_entries_015dc610cd81ede0: function(arg0) {
|
|
115
|
+
const ret = Object.entries(arg0);
|
|
116
|
+
return ret;
|
|
117
|
+
},
|
|
118
|
+
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
119
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
120
|
+
}, arguments); },
|
|
121
|
+
__wbg_get_507a50627bffa49b: function(arg0, arg1) {
|
|
122
|
+
const ret = arg0[arg1 >>> 0];
|
|
123
|
+
return ret;
|
|
124
|
+
},
|
|
125
|
+
__wbg_get_c7eb1f358a7654df: function() { return handleError(function (arg0, arg1) {
|
|
126
|
+
const ret = Reflect.get(arg0, arg1);
|
|
127
|
+
return ret;
|
|
128
|
+
}, arguments); },
|
|
129
|
+
__wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
|
|
130
|
+
const ret = arg0[arg1 >>> 0];
|
|
131
|
+
return ret;
|
|
132
|
+
},
|
|
133
|
+
__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
|
|
134
|
+
let result;
|
|
135
|
+
try {
|
|
136
|
+
result = arg0 instanceof ArrayBuffer;
|
|
137
|
+
} catch (_) {
|
|
138
|
+
result = false;
|
|
139
|
+
}
|
|
140
|
+
const ret = result;
|
|
141
|
+
return ret;
|
|
142
|
+
},
|
|
143
|
+
__wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
|
|
144
|
+
let result;
|
|
145
|
+
try {
|
|
146
|
+
result = arg0 instanceof Map;
|
|
147
|
+
} catch (_) {
|
|
148
|
+
result = false;
|
|
149
|
+
}
|
|
150
|
+
const ret = result;
|
|
151
|
+
return ret;
|
|
152
|
+
},
|
|
153
|
+
__wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
|
|
154
|
+
let result;
|
|
155
|
+
try {
|
|
156
|
+
result = arg0 instanceof Uint8Array;
|
|
157
|
+
} catch (_) {
|
|
158
|
+
result = false;
|
|
159
|
+
}
|
|
160
|
+
const ret = result;
|
|
161
|
+
return ret;
|
|
162
|
+
},
|
|
163
|
+
__wbg_isArray_0677c962b281d01a: function(arg0) {
|
|
164
|
+
const ret = Array.isArray(arg0);
|
|
165
|
+
return ret;
|
|
166
|
+
},
|
|
167
|
+
__wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
|
|
168
|
+
const ret = Number.isSafeInteger(arg0);
|
|
169
|
+
return ret;
|
|
170
|
+
},
|
|
171
|
+
__wbg_iterator_6f722e4a93058b71: function() {
|
|
172
|
+
const ret = Symbol.iterator;
|
|
173
|
+
return ret;
|
|
174
|
+
},
|
|
175
|
+
__wbg_length_1f0964f4a5e2c6d8: function(arg0) {
|
|
176
|
+
const ret = arg0.length;
|
|
177
|
+
return ret;
|
|
178
|
+
},
|
|
179
|
+
__wbg_length_370319915dc99107: function(arg0) {
|
|
180
|
+
const ret = arg0.length;
|
|
181
|
+
return ret;
|
|
182
|
+
},
|
|
183
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
184
|
+
const ret = new Array();
|
|
185
|
+
return ret;
|
|
186
|
+
},
|
|
187
|
+
__wbg_new_cd45aabdf6073e84: function(arg0) {
|
|
188
|
+
const ret = new Uint8Array(arg0);
|
|
189
|
+
return ret;
|
|
190
|
+
},
|
|
191
|
+
__wbg_new_da52cf8fe3429cb2: function() {
|
|
192
|
+
const ret = new Object();
|
|
193
|
+
return ret;
|
|
194
|
+
},
|
|
195
|
+
__wbg_next_6dbf2c0ac8cde20f: function(arg0) {
|
|
196
|
+
const ret = arg0.next;
|
|
197
|
+
return ret;
|
|
198
|
+
},
|
|
199
|
+
__wbg_next_71f2aa1cb3d1e37e: function() { return handleError(function (arg0) {
|
|
200
|
+
const ret = arg0.next();
|
|
201
|
+
return ret;
|
|
202
|
+
}, arguments); },
|
|
203
|
+
__wbg_now_86c0d4ba3fa605b8: function() {
|
|
204
|
+
const ret = Date.now();
|
|
205
|
+
return ret;
|
|
206
|
+
},
|
|
207
|
+
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
208
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
209
|
+
},
|
|
210
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
211
|
+
arg0[arg1] = arg2;
|
|
212
|
+
},
|
|
213
|
+
__wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
|
|
214
|
+
arg0[arg1 >>> 0] = arg2;
|
|
215
|
+
},
|
|
216
|
+
__wbg_value_a5d5488a9589444a: function(arg0) {
|
|
217
|
+
const ret = arg0.value;
|
|
218
|
+
return ret;
|
|
219
|
+
},
|
|
220
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
221
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
222
|
+
const ret = arg0;
|
|
223
|
+
return ret;
|
|
224
|
+
},
|
|
225
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
226
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
227
|
+
const ret = arg0;
|
|
228
|
+
return ret;
|
|
229
|
+
},
|
|
230
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
231
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
232
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
233
|
+
return ret;
|
|
234
|
+
},
|
|
235
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
236
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
237
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
238
|
+
return ret;
|
|
239
|
+
},
|
|
240
|
+
__wbindgen_init_externref_table: function() {
|
|
241
|
+
const table = wasm.__wbindgen_externrefs;
|
|
242
|
+
const offset = table.grow(4);
|
|
243
|
+
table.set(0, undefined);
|
|
244
|
+
table.set(offset + 0, undefined);
|
|
245
|
+
table.set(offset + 1, null);
|
|
246
|
+
table.set(offset + 2, true);
|
|
247
|
+
table.set(offset + 3, false);
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
__proto__: null,
|
|
252
|
+
"./u_routing_bg.js": import0,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function addToExternrefTable0(obj) {
|
|
257
|
+
const idx = wasm.__externref_table_alloc();
|
|
258
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
259
|
+
return idx;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function debugString(val) {
|
|
263
|
+
// primitive types
|
|
264
|
+
const type = typeof val;
|
|
265
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
266
|
+
return `${val}`;
|
|
267
|
+
}
|
|
268
|
+
if (type == 'string') {
|
|
269
|
+
return `"${val}"`;
|
|
270
|
+
}
|
|
271
|
+
if (type == 'symbol') {
|
|
272
|
+
const description = val.description;
|
|
273
|
+
if (description == null) {
|
|
274
|
+
return 'Symbol';
|
|
275
|
+
} else {
|
|
276
|
+
return `Symbol(${description})`;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (type == 'function') {
|
|
280
|
+
const name = val.name;
|
|
281
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
282
|
+
return `Function(${name})`;
|
|
283
|
+
} else {
|
|
284
|
+
return 'Function';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// objects
|
|
288
|
+
if (Array.isArray(val)) {
|
|
289
|
+
const length = val.length;
|
|
290
|
+
let debug = '[';
|
|
291
|
+
if (length > 0) {
|
|
292
|
+
debug += debugString(val[0]);
|
|
293
|
+
}
|
|
294
|
+
for(let i = 1; i < length; i++) {
|
|
295
|
+
debug += ', ' + debugString(val[i]);
|
|
296
|
+
}
|
|
297
|
+
debug += ']';
|
|
298
|
+
return debug;
|
|
299
|
+
}
|
|
300
|
+
// Test for built-in
|
|
301
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
302
|
+
let className;
|
|
303
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
304
|
+
className = builtInMatches[1];
|
|
305
|
+
} else {
|
|
306
|
+
// Failed to match the standard '[object ClassName]'
|
|
307
|
+
return toString.call(val);
|
|
308
|
+
}
|
|
309
|
+
if (className == 'Object') {
|
|
310
|
+
// we're a user defined class or Object
|
|
311
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
312
|
+
// easier than looping through ownProperties of `val`.
|
|
313
|
+
try {
|
|
314
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
315
|
+
} catch (_) {
|
|
316
|
+
return 'Object';
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// errors
|
|
320
|
+
if (val instanceof Error) {
|
|
321
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
322
|
+
}
|
|
323
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
324
|
+
return className;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
328
|
+
ptr = ptr >>> 0;
|
|
329
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let cachedDataViewMemory0 = null;
|
|
333
|
+
function getDataViewMemory0() {
|
|
334
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
335
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
336
|
+
}
|
|
337
|
+
return cachedDataViewMemory0;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function getStringFromWasm0(ptr, len) {
|
|
341
|
+
return decodeText(ptr >>> 0, len);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let cachedUint8ArrayMemory0 = null;
|
|
345
|
+
function getUint8ArrayMemory0() {
|
|
346
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
347
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
348
|
+
}
|
|
349
|
+
return cachedUint8ArrayMemory0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function handleError(f, args) {
|
|
353
|
+
try {
|
|
354
|
+
return f.apply(this, args);
|
|
355
|
+
} catch (e) {
|
|
356
|
+
const idx = addToExternrefTable0(e);
|
|
357
|
+
wasm.__wbindgen_exn_store(idx);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function isLikeNone(x) {
|
|
362
|
+
return x === undefined || x === null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
366
|
+
if (realloc === undefined) {
|
|
367
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
368
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
369
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
370
|
+
WASM_VECTOR_LEN = buf.length;
|
|
371
|
+
return ptr;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let len = arg.length;
|
|
375
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
376
|
+
|
|
377
|
+
const mem = getUint8ArrayMemory0();
|
|
378
|
+
|
|
379
|
+
let offset = 0;
|
|
380
|
+
|
|
381
|
+
for (; offset < len; offset++) {
|
|
382
|
+
const code = arg.charCodeAt(offset);
|
|
383
|
+
if (code > 0x7F) break;
|
|
384
|
+
mem[ptr + offset] = code;
|
|
385
|
+
}
|
|
386
|
+
if (offset !== len) {
|
|
387
|
+
if (offset !== 0) {
|
|
388
|
+
arg = arg.slice(offset);
|
|
389
|
+
}
|
|
390
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
391
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
392
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
393
|
+
|
|
394
|
+
offset += ret.written;
|
|
395
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
WASM_VECTOR_LEN = offset;
|
|
399
|
+
return ptr;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function takeFromExternrefTable0(idx) {
|
|
403
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
404
|
+
wasm.__externref_table_dealloc(idx);
|
|
405
|
+
return value;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
409
|
+
cachedTextDecoder.decode();
|
|
410
|
+
function decodeText(ptr, len) {
|
|
411
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const cachedTextEncoder = new TextEncoder();
|
|
415
|
+
|
|
416
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
417
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
418
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
419
|
+
view.set(buf);
|
|
420
|
+
return {
|
|
421
|
+
read: arg.length,
|
|
422
|
+
written: buf.length
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
let WASM_VECTOR_LEN = 0;
|
|
428
|
+
|
|
429
|
+
const wasmPath = `${__dirname}/u_routing_bg.wasm`;
|
|
430
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
431
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
432
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
433
|
+
let wasm = wasmInstance.exports;
|
|
434
|
+
wasm.__wbindgen_start();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Solve a capacitated VRP problem.
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `problem` — A native JS object matching the VRP input schema.
|
|
9
|
+
*
|
|
10
|
+
* # Supported methods
|
|
11
|
+
* - `"nn"` — Nearest Neighbor (default, fast)
|
|
12
|
+
* - `"savings"` — Clarke-Wright Savings
|
|
13
|
+
* - `"ga"` — Genetic Algorithm with Prins split + local search
|
|
14
|
+
* - `"alns"` — Adaptive Large Neighborhood Search + local search
|
|
15
|
+
*
|
|
16
|
+
* # Returns
|
|
17
|
+
* A JS object with `routes`, `total_distance`, `num_vehicles`,
|
|
18
|
+
* `method_used`, and `computation_time_ms`.
|
|
19
|
+
*
|
|
20
|
+
* # Errors
|
|
21
|
+
* Returns a `JsValue` string describing the error if input is invalid.
|
|
22
|
+
*/
|
|
23
|
+
export function solve_vrp(problem: any): any;
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"iyulab"
|
|
6
6
|
],
|
|
7
7
|
"description": "Vehicle routing optimization: TSP, CVRP, VRPTW with constructive heuristics, local search, GA, and ALNS.",
|
|
8
|
-
"version": "0.3.
|
|
8
|
+
"version": "0.3.2",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
"u_routing_bg.wasm",
|
|
16
16
|
"u_routing.js",
|
|
17
17
|
"u_routing_bg.js",
|
|
18
|
-
"u_routing.d.ts"
|
|
18
|
+
"u_routing.d.ts",
|
|
19
|
+
"node"
|
|
19
20
|
],
|
|
20
21
|
"main": "u_routing.js",
|
|
21
22
|
"types": "u_routing.d.ts",
|
|
22
23
|
"sideEffects": [
|
|
23
24
|
"./u_routing.js",
|
|
24
|
-
"./snippets/*"
|
|
25
|
+
"./snippets/*",
|
|
26
|
+
"./node/u_routing.cjs"
|
|
25
27
|
],
|
|
26
28
|
"keywords": [
|
|
27
29
|
"routing",
|
|
@@ -29,5 +31,16 @@
|
|
|
29
31
|
"tsp",
|
|
30
32
|
"optimization",
|
|
31
33
|
"logistics"
|
|
32
|
-
]
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"node": {
|
|
38
|
+
"types": "./node/u_routing.d.cts",
|
|
39
|
+
"default": "./node/u_routing.cjs"
|
|
40
|
+
},
|
|
41
|
+
"types": "./u_routing.d.ts",
|
|
42
|
+
"default": "./u_routing.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
}
|
|
33
46
|
}
|
package/u_routing_bg.js
CHANGED
|
@@ -26,7 +26,7 @@ export function solve_vrp(problem) {
|
|
|
26
26
|
}
|
|
27
27
|
return takeFromExternrefTable0(ret[0]);
|
|
28
28
|
}
|
|
29
|
-
export function
|
|
29
|
+
export function __wbg_Error_92b29b0548f8b746(arg0, arg1) {
|
|
30
30
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
31
31
|
return ret;
|
|
32
32
|
}
|
|
@@ -37,56 +37,56 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
37
37
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
38
38
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
39
39
|
}
|
|
40
|
-
export function
|
|
40
|
+
export function __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f(arg0, arg1) {
|
|
41
41
|
const v = arg1;
|
|
42
42
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
43
43
|
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
44
44
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
45
45
|
}
|
|
46
|
-
export function
|
|
46
|
+
export function __wbg___wbindgen_boolean_get_fa956cfa2d1bd751(arg0) {
|
|
47
47
|
const v = arg0;
|
|
48
48
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
49
49
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
50
50
|
}
|
|
51
|
-
export function
|
|
51
|
+
export function __wbg___wbindgen_debug_string_c25d447a39f5578f(arg0, arg1) {
|
|
52
52
|
const ret = debugString(arg1);
|
|
53
53
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
54
54
|
const len1 = WASM_VECTOR_LEN;
|
|
55
55
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
56
56
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
57
57
|
}
|
|
58
|
-
export function
|
|
58
|
+
export function __wbg___wbindgen_in_aca499c5de7ff5e5(arg0, arg1) {
|
|
59
59
|
const ret = arg0 in arg1;
|
|
60
60
|
return ret;
|
|
61
61
|
}
|
|
62
|
-
export function
|
|
62
|
+
export function __wbg___wbindgen_is_bigint_2f76dc55065b4273(arg0) {
|
|
63
63
|
const ret = typeof(arg0) === 'bigint';
|
|
64
64
|
return ret;
|
|
65
65
|
}
|
|
66
|
-
export function
|
|
66
|
+
export function __wbg___wbindgen_is_function_1ff95bcc5517c252(arg0) {
|
|
67
67
|
const ret = typeof(arg0) === 'function';
|
|
68
68
|
return ret;
|
|
69
69
|
}
|
|
70
|
-
export function
|
|
70
|
+
export function __wbg___wbindgen_is_object_a27215656b807791(arg0) {
|
|
71
71
|
const val = arg0;
|
|
72
72
|
const ret = typeof(val) === 'object' && val !== null;
|
|
73
73
|
return ret;
|
|
74
74
|
}
|
|
75
|
-
export function
|
|
75
|
+
export function __wbg___wbindgen_jsval_eq_e659fcf7b0e32763(arg0, arg1) {
|
|
76
76
|
const ret = arg0 === arg1;
|
|
77
77
|
return ret;
|
|
78
78
|
}
|
|
79
|
-
export function
|
|
79
|
+
export function __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170(arg0, arg1) {
|
|
80
80
|
const ret = arg0 == arg1;
|
|
81
81
|
return ret;
|
|
82
82
|
}
|
|
83
|
-
export function
|
|
83
|
+
export function __wbg___wbindgen_number_get_394265ed1e1b84ee(arg0, arg1) {
|
|
84
84
|
const obj = arg1;
|
|
85
85
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
86
86
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
87
87
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
88
88
|
}
|
|
89
|
-
export function
|
|
89
|
+
export function __wbg___wbindgen_string_get_b0ca35b86a603356(arg0, arg1) {
|
|
90
90
|
const obj = arg1;
|
|
91
91
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
92
92
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -94,37 +94,37 @@ export function __wbg___wbindgen_string_get_fa2687d531ed17a5(arg0, arg1) {
|
|
|
94
94
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
95
95
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
96
96
|
}
|
|
97
|
-
export function
|
|
97
|
+
export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
|
|
98
98
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
99
99
|
}
|
|
100
|
-
export function
|
|
100
|
+
export function __wbg_call_8a2dd23819f8a60a() { return handleError(function (arg0, arg1) {
|
|
101
101
|
const ret = arg0.call(arg1);
|
|
102
102
|
return ret;
|
|
103
103
|
}, arguments); }
|
|
104
|
-
export function
|
|
104
|
+
export function __wbg_done_89b2b13e91a60321(arg0) {
|
|
105
105
|
const ret = arg0.done;
|
|
106
106
|
return ret;
|
|
107
107
|
}
|
|
108
|
-
export function
|
|
108
|
+
export function __wbg_entries_015dc610cd81ede0(arg0) {
|
|
109
109
|
const ret = Object.entries(arg0);
|
|
110
110
|
return ret;
|
|
111
111
|
}
|
|
112
112
|
export function __wbg_getRandomValues_3f44b700395062e5() { return handleError(function (arg0, arg1) {
|
|
113
113
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
114
114
|
}, arguments); }
|
|
115
|
-
export function
|
|
116
|
-
const ret = Reflect.get(arg0, arg1);
|
|
117
|
-
return ret;
|
|
118
|
-
}, arguments); }
|
|
119
|
-
export function __wbg_get_4b90d6d8c5deb5d5(arg0, arg1) {
|
|
115
|
+
export function __wbg_get_507a50627bffa49b(arg0, arg1) {
|
|
120
116
|
const ret = arg0[arg1 >>> 0];
|
|
121
117
|
return ret;
|
|
122
118
|
}
|
|
123
|
-
export function
|
|
119
|
+
export function __wbg_get_c7eb1f358a7654df() { return handleError(function (arg0, arg1) {
|
|
120
|
+
const ret = Reflect.get(arg0, arg1);
|
|
121
|
+
return ret;
|
|
122
|
+
}, arguments); }
|
|
123
|
+
export function __wbg_get_unchecked_6e0ad6d2a41b06f6(arg0, arg1) {
|
|
124
124
|
const ret = arg0[arg1 >>> 0];
|
|
125
125
|
return ret;
|
|
126
126
|
}
|
|
127
|
-
export function
|
|
127
|
+
export function __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb(arg0) {
|
|
128
128
|
let result;
|
|
129
129
|
try {
|
|
130
130
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -134,7 +134,7 @@ export function __wbg_instanceof_ArrayBuffer_a581da923203f29f(arg0) {
|
|
|
134
134
|
const ret = result;
|
|
135
135
|
return ret;
|
|
136
136
|
}
|
|
137
|
-
export function
|
|
137
|
+
export function __wbg_instanceof_Map_e5b5e3db98422fcc(arg0) {
|
|
138
138
|
let result;
|
|
139
139
|
try {
|
|
140
140
|
result = arg0 instanceof Map;
|
|
@@ -144,7 +144,7 @@ export function __wbg_instanceof_Map_7f94c740225003e2(arg0) {
|
|
|
144
144
|
const ret = result;
|
|
145
145
|
return ret;
|
|
146
146
|
}
|
|
147
|
-
export function
|
|
147
|
+
export function __wbg_instanceof_Uint8Array_309b927aaf7a3fc7(arg0) {
|
|
148
148
|
let result;
|
|
149
149
|
try {
|
|
150
150
|
result = arg0 instanceof Uint8Array;
|
|
@@ -154,60 +154,60 @@ export function __wbg_instanceof_Uint8Array_b6fe1ac89eba107e(arg0) {
|
|
|
154
154
|
const ret = result;
|
|
155
155
|
return ret;
|
|
156
156
|
}
|
|
157
|
-
export function
|
|
157
|
+
export function __wbg_isArray_0677c962b281d01a(arg0) {
|
|
158
158
|
const ret = Array.isArray(arg0);
|
|
159
159
|
return ret;
|
|
160
160
|
}
|
|
161
|
-
export function
|
|
161
|
+
export function __wbg_isSafeInteger_04f36e4056f1b851(arg0) {
|
|
162
162
|
const ret = Number.isSafeInteger(arg0);
|
|
163
163
|
return ret;
|
|
164
164
|
}
|
|
165
|
-
export function
|
|
165
|
+
export function __wbg_iterator_6f722e4a93058b71() {
|
|
166
166
|
const ret = Symbol.iterator;
|
|
167
167
|
return ret;
|
|
168
168
|
}
|
|
169
|
-
export function
|
|
169
|
+
export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
|
|
170
170
|
const ret = arg0.length;
|
|
171
171
|
return ret;
|
|
172
172
|
}
|
|
173
|
-
export function
|
|
173
|
+
export function __wbg_length_370319915dc99107(arg0) {
|
|
174
174
|
const ret = arg0.length;
|
|
175
175
|
return ret;
|
|
176
176
|
}
|
|
177
|
-
export function
|
|
177
|
+
export function __wbg_new_32b398fb48b6d94a() {
|
|
178
178
|
const ret = new Array();
|
|
179
179
|
return ret;
|
|
180
180
|
}
|
|
181
|
-
export function
|
|
181
|
+
export function __wbg_new_cd45aabdf6073e84(arg0) {
|
|
182
|
+
const ret = new Uint8Array(arg0);
|
|
183
|
+
return ret;
|
|
184
|
+
}
|
|
185
|
+
export function __wbg_new_da52cf8fe3429cb2() {
|
|
182
186
|
const ret = new Object();
|
|
183
187
|
return ret;
|
|
184
188
|
}
|
|
185
|
-
export function
|
|
186
|
-
const ret =
|
|
189
|
+
export function __wbg_next_6dbf2c0ac8cde20f(arg0) {
|
|
190
|
+
const ret = arg0.next;
|
|
187
191
|
return ret;
|
|
188
192
|
}
|
|
189
|
-
export function
|
|
193
|
+
export function __wbg_next_71f2aa1cb3d1e37e() { return handleError(function (arg0) {
|
|
190
194
|
const ret = arg0.next();
|
|
191
195
|
return ret;
|
|
192
196
|
}, arguments); }
|
|
193
|
-
export function
|
|
194
|
-
const ret = arg0.next;
|
|
195
|
-
return ret;
|
|
196
|
-
}
|
|
197
|
-
export function __wbg_now_bce4dc999095ea77() {
|
|
197
|
+
export function __wbg_now_86c0d4ba3fa605b8() {
|
|
198
198
|
const ret = Date.now();
|
|
199
199
|
return ret;
|
|
200
200
|
}
|
|
201
|
-
export function
|
|
201
|
+
export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
|
|
202
202
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
203
203
|
}
|
|
204
204
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
205
205
|
arg0[arg1] = arg2;
|
|
206
206
|
}
|
|
207
|
-
export function
|
|
207
|
+
export function __wbg_set_8a16b38e4805b298(arg0, arg1, arg2) {
|
|
208
208
|
arg0[arg1 >>> 0] = arg2;
|
|
209
209
|
}
|
|
210
|
-
export function
|
|
210
|
+
export function __wbg_value_a5d5488a9589444a(arg0) {
|
|
211
211
|
const ret = arg0.value;
|
|
212
212
|
return ret;
|
|
213
213
|
}
|
package/u_routing_bg.wasm
CHANGED
|
Binary file
|