@iyulab/u-metaheur 0.4.3 → 0.5.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 CHANGED
@@ -78,10 +78,10 @@ assert!((result.best - 3.0).abs() < 0.1);
78
78
 
79
79
  ```toml
80
80
  [dependencies]
81
- u-metaheur = "0.4"
81
+ u-metaheur = "0.5"
82
82
 
83
83
  # with serde support
84
- u-metaheur = { version = "0.4", features = ["serde"] }
84
+ u-metaheur = { version = "0.5", features = ["serde"] }
85
85
  ```
86
86
 
87
87
  ## Build & Test
@@ -116,6 +116,11 @@ The package resolves per environment via a conditional `exports` map:
116
116
  | Bundlers (webpack, Vite, …) | ESM + WebAssembly ESM-integration (`default` condition) |
117
117
  | 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 |
118
118
 
119
+ A browser **without** a bundler is not supported: the package loads its `.wasm`
120
+ file with an ES module import, which browsers refuse (`application/wasm` is not a
121
+ module script type), so `<script type="module">` from a CDN fails, and CDN
122
+ re-bundling services fail on the same import. Use a bundler or Node.
123
+
119
124
  ### Quick Start
120
125
 
121
126
  Both functions solve a travelling-salesman tour over `nodes` (`[x, y]` pairs)
@@ -137,6 +142,28 @@ console.log(sa.best_distance, sa.iterations_run);
137
142
  `cooling_rate`. Every setting is optional except `nodes`, and a setting the
138
143
  function does not have is rejected rather than ignored.
139
144
 
145
+ ### Errors
146
+
147
+ A refusal throws an `Error` whose `message` is readable text and which carries a
148
+ `code` naming the reason, next to the values behind it:
149
+
150
+ ```js
151
+ import { run_sa } from '@iyulab/u-metaheur';
152
+
153
+ try {
154
+ run_sa({ nodes: [[0, 0], [1, 0], [1, 1]], cooling_rate: 1 });
155
+ } catch (err) {
156
+ console.log(err.code, err.parameter, err.min, err.max, err.got); // parameter_out_of_range cooling_rate 0 1 1
157
+ }
158
+ ```
159
+
160
+ | `code` | Fields | Meaning |
161
+ |---|---|---|
162
+ | `insufficient_data` | `parameter` (`"nodes"`), `min`, `got` | Fewer than 2 nodes |
163
+ | `parameter_out_of_range` | `parameter`, `min`, `max` (or `null`), `got` | `population_size < 2`, `generations` or `iterations` of 0, `initial_temp ≤ 0`, or `cooling_rate` outside (0, 1) — the message says whether a bound is included |
164
+ | `value_not_finite` | `parameter`, `index` | A NaN or ±Infinity anywhere in an argument — `parameter` is the path to it (`config.nodes[1]`), `index` its position in that array, or `null` |
165
+ | `malformed_input` | `parameter` | An argument of the wrong shape or type (a missing or unknown key), or a JSON string |
166
+
140
167
  ### TypeScript
141
168
 
142
169
  Every exported function declares its parameter and return types, and the
@@ -99,6 +99,10 @@ function __wbg_get_imports() {
99
99
  const ret = typeof(val) === 'object' && val !== null;
100
100
  return ret;
101
101
  },
102
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
103
+ const ret = typeof(arg0) === 'string';
104
+ return ret;
105
+ },
102
106
  __wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
103
107
  const ret = arg0 === arg1;
104
108
  return ret;
@@ -124,6 +128,10 @@ function __wbg_get_imports() {
124
128
  __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
125
129
  throw new Error(getStringFromWasm0(arg0, arg1));
126
130
  },
131
+ __wbg_assign_e39d243f5fbe1e2d: function(arg0, arg1) {
132
+ const ret = Object.assign(arg0, arg1);
133
+ return ret;
134
+ },
127
135
  __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
128
136
  const ret = arg0.call(arg1);
129
137
  return ret;
@@ -205,6 +213,14 @@ function __wbg_get_imports() {
205
213
  const ret = new Uint8Array(arg0);
206
214
  return ret;
207
215
  },
216
+ __wbg_new_28744009d011f847: function() {
217
+ const ret = new Map();
218
+ return ret;
219
+ },
220
+ __wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
221
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
222
+ return ret;
223
+ },
208
224
  __wbg_new_617a8cdb8bb1130e: function() {
209
225
  const ret = new Object();
210
226
  return ret;
@@ -224,6 +240,10 @@ function __wbg_get_imports() {
224
240
  __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
225
241
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
226
242
  },
243
+ __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
244
+ const ret = arg0.set(arg1, arg2);
245
+ return ret;
246
+ },
227
247
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
228
248
  arg0[arg1] = arg2;
229
249
  },
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "iyulab"
6
6
  ],
7
7
  "description": "Domain-agnostic metaheuristic optimization framework: GA, BRKGA, SA, ALNS.",
8
- "version": "0.4.3",
8
+ "version": "0.5.1",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
package/u_metaheur_bg.js CHANGED
@@ -92,6 +92,10 @@ export function __wbg___wbindgen_is_object_3c45d4f2dde4e749(arg0) {
92
92
  const ret = typeof(val) === 'object' && val !== null;
93
93
  return ret;
94
94
  }
95
+ export function __wbg___wbindgen_is_string_90b56bc79aad6f6c(arg0) {
96
+ const ret = typeof(arg0) === 'string';
97
+ return ret;
98
+ }
95
99
  export function __wbg___wbindgen_jsval_eq_02babf21faa37971(arg0, arg1) {
96
100
  const ret = arg0 === arg1;
97
101
  return ret;
@@ -117,6 +121,10 @@ export function __wbg___wbindgen_string_get_0380ccaa2f57f0d9(arg0, arg1) {
117
121
  export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
118
122
  throw new Error(getStringFromWasm0(arg0, arg1));
119
123
  }
124
+ export function __wbg_assign_e39d243f5fbe1e2d(arg0, arg1) {
125
+ const ret = Object.assign(arg0, arg1);
126
+ return ret;
127
+ }
120
128
  export function __wbg_call_6137034ef55c9d0f() { return handleError(function (arg0, arg1) {
121
129
  const ret = arg0.call(arg1);
122
130
  return ret;
@@ -198,6 +206,14 @@ export function __wbg_new_1dbf7428bba60a42(arg0) {
198
206
  const ret = new Uint8Array(arg0);
199
207
  return ret;
200
208
  }
209
+ export function __wbg_new_28744009d011f847() {
210
+ const ret = new Map();
211
+ return ret;
212
+ }
213
+ export function __wbg_new_343a093a3c2ffb4e(arg0, arg1) {
214
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
215
+ return ret;
216
+ }
201
217
  export function __wbg_new_617a8cdb8bb1130e() {
202
218
  const ret = new Object();
203
219
  return ret;
@@ -217,6 +233,10 @@ export function __wbg_next_f4aac29c42af995c() { return handleError(function (arg
217
233
  export function __wbg_prototypesetcall_bc27214492979395(arg0, arg1, arg2) {
218
234
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
219
235
  }
236
+ export function __wbg_set_6ae97e73113c4f0b(arg0, arg1, arg2) {
237
+ const ret = arg0.set(arg1, arg2);
238
+ return ret;
239
+ }
220
240
  export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
221
241
  arg0[arg1] = arg2;
222
242
  }
Binary file