@iyulab/u-schedule 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 iyulab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # u-schedule
2
+
3
+ **Scheduling framework in Rust**
4
+
5
+ [![Crates.io](https://img.shields.io/crates/v/u-schedule.svg)](https://crates.io/crates/u-schedule)
6
+ [![docs.rs](https://docs.rs/u-schedule/badge.svg)](https://docs.rs/u-schedule)
7
+ [![CI](https://github.com/iyulab/u-schedule/actions/workflows/ci.yml/badge.svg)](https://github.com/iyulab/u-schedule/actions/workflows/ci.yml)
8
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
+
10
+ ## Overview
11
+
12
+ u-schedule provides domain models, constraints, validation, dispatching rules, and a greedy scheduler for scheduling problems. It builds on `u-metaheur` for metaheuristic algorithms and `u-numflow` for mathematical primitives.
13
+
14
+ ## Modules
15
+
16
+ | Module | Description |
17
+ |--------|-------------|
18
+ | `models` | Domain types: `Task`, `Activity`, `Resource`, `Schedule`, `Assignment`, `Calendar`, `Constraint`, `TransitionMatrix` |
19
+ | `validation` | Input integrity checks: duplicate IDs, DAG cycle detection, resource reference validation |
20
+ | `dispatching` | Priority dispatching rules and rule engine |
21
+ | `scheduler` | Greedy scheduler and KPI evaluation |
22
+ | `ga` | GA-based scheduling with OSV/MAV dual-vector encoding |
23
+ | `cp` | CP-based scheduling formulation |
24
+
25
+ ## Dispatching Rules
26
+
27
+ | Rule | Description |
28
+ |------|-------------|
29
+ | SPT | Shortest Processing Time |
30
+ | LPT | Longest Processing Time |
31
+ | EDD | Earliest Due Date |
32
+ | FIFO | First In First Out |
33
+ | SLACK | Minimum Slack Time |
34
+ | CR | Critical Ratio |
35
+ | ATC | Apparent Tardiness Cost |
36
+ | WSPT | Weighted Shortest Processing Time |
37
+ | MWKR | Most Work Remaining |
38
+ | LWKR | Least Work Remaining |
39
+ | MOPNR | Most Operations Remaining |
40
+ | PRIORITY | Job Priority |
41
+ | RANDOM | Random Selection |
42
+
43
+ ## GA Encoding
44
+
45
+ The GA module uses dual-vector encoding for job-shop scheduling:
46
+
47
+ - **OSV (Operation Sequence Vector)** — Permutation encoding that determines operation processing order
48
+ - **MAV (Machine Assignment Vector)** — Integer vector that assigns each operation to a specific machine (for flexible job shops)
49
+
50
+ ## Quick Start
51
+
52
+ ```toml
53
+ [dependencies]
54
+ u-schedule = { git = "https://github.com/iyulab/u-schedule" }
55
+ ```
56
+
57
+ ```rust
58
+ use u_schedule::models::{Task, Activity, Resource};
59
+ use u_schedule::validation::validate_input;
60
+ use u_schedule::dispatching::{DispatchingEngine, Rule};
61
+
62
+ // Define tasks with activities
63
+ let task = Task::new("T1")
64
+ .with_activity(Activity::new("A1", 30_000)); // 30 seconds
65
+
66
+ let resource = Resource::new("R1", "Machine 1");
67
+
68
+ // Validate input
69
+ let errors = validate_input(&[task], &[resource]);
70
+ assert!(errors.is_empty());
71
+ ```
72
+
73
+ ## Build & Test
74
+
75
+ ```bash
76
+ cargo build
77
+ cargo test
78
+ ```
79
+
80
+ ## Academic References
81
+
82
+ - Pinedo (2016), *Scheduling: Theory, Algorithms, and Systems*
83
+ - Brucker (2007), *Scheduling Algorithms*
84
+ - Blazewicz et al. (2019), *Handbook on Scheduling*
85
+ - Haupt (1989), *A Survey of Priority Rule-Based Scheduling*
86
+
87
+ ## Dependencies
88
+
89
+ - [u-metaheur](https://github.com/iyulab/u-metaheur) — Metaheuristic algorithms (GA, SA, ALNS, CP)
90
+ - [u-numflow](https://github.com/iyulab/u-numflow) — Mathematical primitives (statistics, RNG)
91
+ - `serde` 1.0 — Serialization
92
+ - `rand` 0.9 — Random number generation
93
+
94
+ ## License
95
+
96
+ MIT License — see [LICENSE](LICENSE).
97
+
98
+ ## Related
99
+
100
+ - [u-numflow](https://github.com/iyulab/u-numflow) — Mathematical primitives
101
+ - [u-metaheur](https://github.com/iyulab/u-metaheur) — Metaheuristic optimization (GA, SA, ALNS, CP)
102
+ - [u-geometry](https://github.com/iyulab/u-geometry) — Computational geometry
103
+ - [u-nesting](https://github.com/iyulab/U-Nesting) — 2D/3D nesting and bin packing
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@iyulab/u-schedule",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "iyulab"
6
+ ],
7
+ "description": "Domain-agnostic scheduling framework: job-shop models, dispatching rules, GA encoding, constraint programming.",
8
+ "version": "0.1.0",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/iyulab/u-schedule"
13
+ },
14
+ "files": [
15
+ "u_schedule_bg.wasm",
16
+ "u_schedule.js",
17
+ "u_schedule_bg.js",
18
+ "u_schedule.d.ts"
19
+ ],
20
+ "main": "u_schedule.js",
21
+ "types": "u_schedule.d.ts",
22
+ "sideEffects": [
23
+ "./u_schedule.js",
24
+ "./snippets/*"
25
+ ],
26
+ "keywords": [
27
+ "scheduling",
28
+ "job-shop",
29
+ "optimization",
30
+ "manufacturing"
31
+ ]
32
+ }
@@ -0,0 +1,13 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Run a single-machine dispatching schedule.
6
+ *
7
+ * # Arguments
8
+ * `jobs_json` — A JS object matching `ScheduleInput` (see module docs).
9
+ *
10
+ * # Returns
11
+ * A JS object matching `ScheduleOutput` on success, or a JS string error.
12
+ */
13
+ export function run_schedule(jobs_json: any): any;
package/u_schedule.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./u_schedule.d.ts" */
2
+
3
+ import * as wasm from "./u_schedule_bg.wasm";
4
+ import { __wbg_set_wasm } from "./u_schedule_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ run_schedule
9
+ } from "./u_schedule_bg.js";
@@ -0,0 +1,374 @@
1
+ /**
2
+ * Run a single-machine dispatching schedule.
3
+ *
4
+ * # Arguments
5
+ * `jobs_json` — A JS object matching `ScheduleInput` (see module docs).
6
+ *
7
+ * # Returns
8
+ * A JS object matching `ScheduleOutput` on success, or a JS string error.
9
+ * @param {any} jobs_json
10
+ * @returns {any}
11
+ */
12
+ export function run_schedule(jobs_json) {
13
+ const ret = wasm.run_schedule(jobs_json);
14
+ if (ret[2]) {
15
+ throw takeFromExternrefTable0(ret[1]);
16
+ }
17
+ return takeFromExternrefTable0(ret[0]);
18
+ }
19
+ export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
20
+ const ret = Error(getStringFromWasm0(arg0, arg1));
21
+ return ret;
22
+ }
23
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
24
+ const ret = String(arg1);
25
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
26
+ const len1 = WASM_VECTOR_LEN;
27
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
28
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
29
+ }
30
+ export function __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1(arg0) {
31
+ const v = arg0;
32
+ const ret = typeof(v) === 'boolean' ? v : undefined;
33
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
34
+ }
35
+ export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
36
+ const ret = debugString(arg1);
37
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len1 = WASM_VECTOR_LEN;
39
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
40
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
41
+ }
42
+ export function __wbg___wbindgen_in_41dbb8413020e076(arg0, arg1) {
43
+ const ret = arg0 in arg1;
44
+ return ret;
45
+ }
46
+ export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
47
+ const ret = typeof(arg0) === 'function';
48
+ return ret;
49
+ }
50
+ export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
51
+ const val = arg0;
52
+ const ret = typeof(val) === 'object' && val !== null;
53
+ return ret;
54
+ }
55
+ export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
56
+ const ret = arg0 === undefined;
57
+ return ret;
58
+ }
59
+ export function __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b(arg0, arg1) {
60
+ const ret = arg0 == arg1;
61
+ return ret;
62
+ }
63
+ export function __wbg___wbindgen_number_get_34bb9d9dcfa21373(arg0, arg1) {
64
+ const obj = arg1;
65
+ const ret = typeof(obj) === 'number' ? obj : undefined;
66
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
67
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
68
+ }
69
+ export function __wbg___wbindgen_string_get_395e606bd0ee4427(arg0, arg1) {
70
+ const obj = arg1;
71
+ const ret = typeof(obj) === 'string' ? obj : undefined;
72
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
+ var len1 = WASM_VECTOR_LEN;
74
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
75
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
76
+ }
77
+ export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
78
+ throw new Error(getStringFromWasm0(arg0, arg1));
79
+ }
80
+ export function __wbg_call_e133b57c9155d22c() { return handleError(function (arg0, arg1) {
81
+ const ret = arg0.call(arg1);
82
+ return ret;
83
+ }, arguments); }
84
+ export function __wbg_done_08ce71ee07e3bd17(arg0) {
85
+ const ret = arg0.done;
86
+ return ret;
87
+ }
88
+ export function __wbg_get_326e41e095fb2575() { return handleError(function (arg0, arg1) {
89
+ const ret = Reflect.get(arg0, arg1);
90
+ return ret;
91
+ }, arguments); }
92
+ export function __wbg_get_unchecked_329cfe50afab7352(arg0, arg1) {
93
+ const ret = arg0[arg1 >>> 0];
94
+ return ret;
95
+ }
96
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
97
+ const ret = arg0[arg1];
98
+ return ret;
99
+ }
100
+ export function __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6(arg0) {
101
+ let result;
102
+ try {
103
+ result = arg0 instanceof ArrayBuffer;
104
+ } catch (_) {
105
+ result = false;
106
+ }
107
+ const ret = result;
108
+ return ret;
109
+ }
110
+ export function __wbg_instanceof_Uint8Array_740438561a5b956d(arg0) {
111
+ let result;
112
+ try {
113
+ result = arg0 instanceof Uint8Array;
114
+ } catch (_) {
115
+ result = false;
116
+ }
117
+ const ret = result;
118
+ return ret;
119
+ }
120
+ export function __wbg_isArray_33b91feb269ff46e(arg0) {
121
+ const ret = Array.isArray(arg0);
122
+ return ret;
123
+ }
124
+ export function __wbg_iterator_d8f549ec8fb061b1() {
125
+ const ret = Symbol.iterator;
126
+ return ret;
127
+ }
128
+ export function __wbg_length_b3416cf66a5452c8(arg0) {
129
+ const ret = arg0.length;
130
+ return ret;
131
+ }
132
+ export function __wbg_length_ea16607d7b61445b(arg0) {
133
+ const ret = arg0.length;
134
+ return ret;
135
+ }
136
+ export function __wbg_new_5f486cdf45a04d78(arg0) {
137
+ const ret = new Uint8Array(arg0);
138
+ return ret;
139
+ }
140
+ export function __wbg_new_a70fbab9066b301f() {
141
+ const ret = new Array();
142
+ return ret;
143
+ }
144
+ export function __wbg_new_ab79df5bd7c26067() {
145
+ const ret = new Object();
146
+ return ret;
147
+ }
148
+ export function __wbg_next_11b99ee6237339e3() { return handleError(function (arg0) {
149
+ const ret = arg0.next();
150
+ return ret;
151
+ }, arguments); }
152
+ export function __wbg_next_e01a967809d1aa68(arg0) {
153
+ const ret = arg0.next;
154
+ return ret;
155
+ }
156
+ export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
157
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
158
+ }
159
+ export function __wbg_set_282384002438957f(arg0, arg1, arg2) {
160
+ arg0[arg1 >>> 0] = arg2;
161
+ }
162
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
163
+ arg0[arg1] = arg2;
164
+ }
165
+ export function __wbg_value_21fc78aab0322612(arg0) {
166
+ const ret = arg0.value;
167
+ return ret;
168
+ }
169
+ export function __wbindgen_cast_0000000000000001(arg0) {
170
+ // Cast intrinsic for `F64 -> Externref`.
171
+ const ret = arg0;
172
+ return ret;
173
+ }
174
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
175
+ // Cast intrinsic for `Ref(String) -> Externref`.
176
+ const ret = getStringFromWasm0(arg0, arg1);
177
+ return ret;
178
+ }
179
+ export function __wbindgen_init_externref_table() {
180
+ const table = wasm.__wbindgen_externrefs;
181
+ const offset = table.grow(4);
182
+ table.set(0, undefined);
183
+ table.set(offset + 0, undefined);
184
+ table.set(offset + 1, null);
185
+ table.set(offset + 2, true);
186
+ table.set(offset + 3, false);
187
+ }
188
+ function addToExternrefTable0(obj) {
189
+ const idx = wasm.__externref_table_alloc();
190
+ wasm.__wbindgen_externrefs.set(idx, obj);
191
+ return idx;
192
+ }
193
+
194
+ function debugString(val) {
195
+ // primitive types
196
+ const type = typeof val;
197
+ if (type == 'number' || type == 'boolean' || val == null) {
198
+ return `${val}`;
199
+ }
200
+ if (type == 'string') {
201
+ return `"${val}"`;
202
+ }
203
+ if (type == 'symbol') {
204
+ const description = val.description;
205
+ if (description == null) {
206
+ return 'Symbol';
207
+ } else {
208
+ return `Symbol(${description})`;
209
+ }
210
+ }
211
+ if (type == 'function') {
212
+ const name = val.name;
213
+ if (typeof name == 'string' && name.length > 0) {
214
+ return `Function(${name})`;
215
+ } else {
216
+ return 'Function';
217
+ }
218
+ }
219
+ // objects
220
+ if (Array.isArray(val)) {
221
+ const length = val.length;
222
+ let debug = '[';
223
+ if (length > 0) {
224
+ debug += debugString(val[0]);
225
+ }
226
+ for(let i = 1; i < length; i++) {
227
+ debug += ', ' + debugString(val[i]);
228
+ }
229
+ debug += ']';
230
+ return debug;
231
+ }
232
+ // Test for built-in
233
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
234
+ let className;
235
+ if (builtInMatches && builtInMatches.length > 1) {
236
+ className = builtInMatches[1];
237
+ } else {
238
+ // Failed to match the standard '[object ClassName]'
239
+ return toString.call(val);
240
+ }
241
+ if (className == 'Object') {
242
+ // we're a user defined class or Object
243
+ // JSON.stringify avoids problems with cycles, and is generally much
244
+ // easier than looping through ownProperties of `val`.
245
+ try {
246
+ return 'Object(' + JSON.stringify(val) + ')';
247
+ } catch (_) {
248
+ return 'Object';
249
+ }
250
+ }
251
+ // errors
252
+ if (val instanceof Error) {
253
+ return `${val.name}: ${val.message}\n${val.stack}`;
254
+ }
255
+ // TODO we could test for more things here, like `Set`s and `Map`s.
256
+ return className;
257
+ }
258
+
259
+ function getArrayU8FromWasm0(ptr, len) {
260
+ ptr = ptr >>> 0;
261
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
262
+ }
263
+
264
+ let cachedDataViewMemory0 = null;
265
+ function getDataViewMemory0() {
266
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
267
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
268
+ }
269
+ return cachedDataViewMemory0;
270
+ }
271
+
272
+ function getStringFromWasm0(ptr, len) {
273
+ ptr = ptr >>> 0;
274
+ return decodeText(ptr, len);
275
+ }
276
+
277
+ let cachedUint8ArrayMemory0 = null;
278
+ function getUint8ArrayMemory0() {
279
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
280
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
281
+ }
282
+ return cachedUint8ArrayMemory0;
283
+ }
284
+
285
+ function handleError(f, args) {
286
+ try {
287
+ return f.apply(this, args);
288
+ } catch (e) {
289
+ const idx = addToExternrefTable0(e);
290
+ wasm.__wbindgen_exn_store(idx);
291
+ }
292
+ }
293
+
294
+ function isLikeNone(x) {
295
+ return x === undefined || x === null;
296
+ }
297
+
298
+ function passStringToWasm0(arg, malloc, realloc) {
299
+ if (realloc === undefined) {
300
+ const buf = cachedTextEncoder.encode(arg);
301
+ const ptr = malloc(buf.length, 1) >>> 0;
302
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
303
+ WASM_VECTOR_LEN = buf.length;
304
+ return ptr;
305
+ }
306
+
307
+ let len = arg.length;
308
+ let ptr = malloc(len, 1) >>> 0;
309
+
310
+ const mem = getUint8ArrayMemory0();
311
+
312
+ let offset = 0;
313
+
314
+ for (; offset < len; offset++) {
315
+ const code = arg.charCodeAt(offset);
316
+ if (code > 0x7F) break;
317
+ mem[ptr + offset] = code;
318
+ }
319
+ if (offset !== len) {
320
+ if (offset !== 0) {
321
+ arg = arg.slice(offset);
322
+ }
323
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
324
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
325
+ const ret = cachedTextEncoder.encodeInto(arg, view);
326
+
327
+ offset += ret.written;
328
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
329
+ }
330
+
331
+ WASM_VECTOR_LEN = offset;
332
+ return ptr;
333
+ }
334
+
335
+ function takeFromExternrefTable0(idx) {
336
+ const value = wasm.__wbindgen_externrefs.get(idx);
337
+ wasm.__externref_table_dealloc(idx);
338
+ return value;
339
+ }
340
+
341
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
342
+ cachedTextDecoder.decode();
343
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
344
+ let numBytesDecoded = 0;
345
+ function decodeText(ptr, len) {
346
+ numBytesDecoded += len;
347
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
348
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
349
+ cachedTextDecoder.decode();
350
+ numBytesDecoded = len;
351
+ }
352
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
353
+ }
354
+
355
+ const cachedTextEncoder = new TextEncoder();
356
+
357
+ if (!('encodeInto' in cachedTextEncoder)) {
358
+ cachedTextEncoder.encodeInto = function (arg, view) {
359
+ const buf = cachedTextEncoder.encode(arg);
360
+ view.set(buf);
361
+ return {
362
+ read: arg.length,
363
+ written: buf.length
364
+ };
365
+ };
366
+ }
367
+
368
+ let WASM_VECTOR_LEN = 0;
369
+
370
+
371
+ let wasm;
372
+ export function __wbg_set_wasm(val) {
373
+ wasm = val;
374
+ }
Binary file