@iyulab/u-metaheur 0.4.0 → 0.4.1
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 +17 -0
- package/node/u_metaheur.cjs +2 -2
- package/node/u_metaheur.d.cts +14 -2
- package/node/u_metaheur_bg.wasm +0 -0
- package/package.json +1 -1
- package/u_metaheur.d.ts +14 -2
- package/u_metaheur_bg.js +2 -2
- package/u_metaheur_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -98,6 +98,23 @@ The package resolves per environment via a conditional `exports` map:
|
|
|
98
98
|
| Bundlers (webpack, Vite, …) | ESM + WebAssembly ESM-integration (`default` condition) |
|
|
99
99
|
| 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 |
|
|
100
100
|
|
|
101
|
+
### TypeScript
|
|
102
|
+
|
|
103
|
+
Every exported function declares its return type, and the declarations are
|
|
104
|
+
generated from the same structs the binding serialises, so they cannot drift
|
|
105
|
+
from what it actually returns:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
export function run_ga(problem: any): GaResult;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
An absent optional value is declared `T | undefined`, which is what the binding
|
|
112
|
+
sends. Nothing needs an `as` cast -- and a wrong assumption about a result's
|
|
113
|
+
shape is a compile error rather than something that fails at run time.
|
|
114
|
+
|
|
115
|
+
Inputs are still `any`: they are validated at the boundary, and a rejected one
|
|
116
|
+
says what was wrong.
|
|
117
|
+
|
|
101
118
|
## Related
|
|
102
119
|
|
|
103
120
|
- [u-numflow](https://github.com/iyulab/u-numflow) — Mathematical primitives
|
package/node/u_metaheur.cjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* # Returns
|
|
14
14
|
* JS object with `best_distance`, `best_tour`, `generations_run`.
|
|
15
15
|
* @param {any} config
|
|
16
|
-
* @returns {
|
|
16
|
+
* @returns {GaResult}
|
|
17
17
|
*/
|
|
18
18
|
function run_ga(config) {
|
|
19
19
|
const ret = wasm.run_ga(config);
|
|
@@ -40,7 +40,7 @@ exports.run_ga = run_ga;
|
|
|
40
40
|
* # Returns
|
|
41
41
|
* JS object with `best_distance`, `best_tour`, `iterations_run`.
|
|
42
42
|
* @param {any} config
|
|
43
|
-
* @returns {
|
|
43
|
+
* @returns {SaResult}
|
|
44
44
|
*/
|
|
45
45
|
function run_sa(config) {
|
|
46
46
|
const ret = wasm.run_sa(config);
|
package/node/u_metaheur.d.cts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export interface GaResult {
|
|
4
|
+
best_distance: number;
|
|
5
|
+
best_tour: number[];
|
|
6
|
+
generations_run: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SaResult {
|
|
10
|
+
best_distance: number;
|
|
11
|
+
best_tour: number[];
|
|
12
|
+
iterations_run: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
|
|
4
16
|
/**
|
|
5
17
|
* Runs a Genetic Algorithm for TSP.
|
|
@@ -14,7 +26,7 @@
|
|
|
14
26
|
* # Returns
|
|
15
27
|
* JS object with `best_distance`, `best_tour`, `generations_run`.
|
|
16
28
|
*/
|
|
17
|
-
export function run_ga(config: any):
|
|
29
|
+
export function run_ga(config: any): GaResult;
|
|
18
30
|
|
|
19
31
|
/**
|
|
20
32
|
* Runs Simulated Annealing for TSP.
|
|
@@ -32,4 +44,4 @@ export function run_ga(config: any): any;
|
|
|
32
44
|
* # Returns
|
|
33
45
|
* JS object with `best_distance`, `best_tour`, `iterations_run`.
|
|
34
46
|
*/
|
|
35
|
-
export function run_sa(config: any):
|
|
47
|
+
export function run_sa(config: any): SaResult;
|
package/node/u_metaheur_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/u_metaheur.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export interface GaResult {
|
|
4
|
+
best_distance: number;
|
|
5
|
+
best_tour: number[];
|
|
6
|
+
generations_run: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SaResult {
|
|
10
|
+
best_distance: number;
|
|
11
|
+
best_tour: number[];
|
|
12
|
+
iterations_run: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
|
|
4
16
|
/**
|
|
5
17
|
* Runs a Genetic Algorithm for TSP.
|
|
@@ -14,7 +26,7 @@
|
|
|
14
26
|
* # Returns
|
|
15
27
|
* JS object with `best_distance`, `best_tour`, `generations_run`.
|
|
16
28
|
*/
|
|
17
|
-
export function run_ga(config: any):
|
|
29
|
+
export function run_ga(config: any): GaResult;
|
|
18
30
|
|
|
19
31
|
/**
|
|
20
32
|
* Runs Simulated Annealing for TSP.
|
|
@@ -32,4 +44,4 @@ export function run_ga(config: any): any;
|
|
|
32
44
|
* # Returns
|
|
33
45
|
* JS object with `best_distance`, `best_tour`, `iterations_run`.
|
|
34
46
|
*/
|
|
35
|
-
export function run_sa(config: any):
|
|
47
|
+
export function run_sa(config: any): SaResult;
|
package/u_metaheur_bg.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* # Returns
|
|
12
12
|
* JS object with `best_distance`, `best_tour`, `generations_run`.
|
|
13
13
|
* @param {any} config
|
|
14
|
-
* @returns {
|
|
14
|
+
* @returns {GaResult}
|
|
15
15
|
*/
|
|
16
16
|
export function run_ga(config) {
|
|
17
17
|
const ret = wasm.run_ga(config);
|
|
@@ -37,7 +37,7 @@ export function run_ga(config) {
|
|
|
37
37
|
* # Returns
|
|
38
38
|
* JS object with `best_distance`, `best_tour`, `iterations_run`.
|
|
39
39
|
* @param {any} config
|
|
40
|
-
* @returns {
|
|
40
|
+
* @returns {SaResult}
|
|
41
41
|
*/
|
|
42
42
|
export function run_sa(config) {
|
|
43
43
|
const ret = wasm.run_sa(config);
|
package/u_metaheur_bg.wasm
CHANGED
|
Binary file
|