@ohtaman/washi 0.8.2 → 0.9.0-rc.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 +3 -0
- package/dist/browser/solvers/{highs-__vite-browser-external-Dn-83hnF.js → highs-__vite-browser-external-xcxOpLMD.js} +1 -1
- package/dist/browser/solvers/{highs-browser-runtime-0Bgq5ksG.js → highs-browser-runtime-ccRmE4qj.js} +1 -1
- package/dist/browser/solvers/highs-inline.js +51 -0
- package/dist/{lib/solvers/loader-CDpPXN_F.js → browser/solvers/highs-loader-Csn3-0tq.js} +241 -149
- package/dist/browser/solvers/highs-worker.js +17 -16
- package/dist/browser/solvers/highs.js +295 -255
- package/dist/browser/solvers/pumpkin-inline.js +51 -0
- package/dist/{lib/solvers/loader-Ow74Fa1B.js → browser/solvers/pumpkin-loader-BI3n3dWO.js} +145 -55
- package/dist/browser/solvers/pumpkin-worker.js +24 -23
- package/dist/browser/solvers/pumpkin.js +307 -288
- package/dist/browser/washi.min.js +4 -4
- package/dist/lib/solvers/embedded-wasm-CSFlLV5N.js +49 -0
- package/dist/lib/solvers/highs-node-runtime.js +1 -7
- package/dist/lib/solvers/highs-worker.js +19 -17
- package/dist/lib/solvers/highs.js +153 -112
- package/dist/{browser/solvers/highs-loader-BLY3wzDH.js → lib/solvers/loader-DCtyxsfF.js} +56 -36
- package/dist/{browser/solvers/pumpkin-loader-CvdaKxf4.js → lib/solvers/loader-b5PNpCmX.js} +58 -33
- package/dist/lib/solvers/pumpkin-worker.js +25 -23
- package/dist/lib/solvers/pumpkin.js +212 -192
- package/dist/types/modeler/solvers/embedded-wasm.d.ts +36 -0
- package/dist/types/modeler/solvers/embedded-wasm.d.ts.map +1 -0
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/inline-pack.d.ts +6 -0
- package/dist/types/modeler/solvers/inline-pack.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +1 -1
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -1
- package/docs/getting-started/ai-agents.md +55 -1
- package/docs/getting-started/runtimes.md +46 -1
- package/docs/solvers/highs.md +2 -0
- package/docs/solvers/pumpkin.md +2 -0
- package/llms-full.txt +105 -2
- package/llms.txt +55 -1
- package/package.json +12 -1
- package/skills/washi/SKILL.md +66 -2
- package/skills/washi-single-html/SKILL.md +335 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type EmbeddedWasmSolver = "highs" | "pumpkin";
|
|
2
|
+
/**
|
|
3
|
+
* Compatibility identifiers derived from `highs.config.json` / `pumpkin.config.json`
|
|
4
|
+
* (`${version}:${wasmSha256.slice(0, 16)}:${runtimeSha256.slice(0, 16)}`).
|
|
5
|
+
* Build scripts verify these match the on-disk WASM and runtime glue at build time.
|
|
6
|
+
*/
|
|
7
|
+
export declare const HIGHS_EMBEDDED_WASM_COMPAT_ID = "v1.16.0:d1c2cb62726e24a7:2bd77844c41e9c91";
|
|
8
|
+
export declare const PUMPKIN_EMBEDDED_WASM_COMPAT_ID = "0.5.0:fc7ddaf3ae17fcc8:ea94cc1b794de550";
|
|
9
|
+
export interface EmbeddedWasmProvider {
|
|
10
|
+
readonly solver: EmbeddedWasmSolver;
|
|
11
|
+
readonly compatId: string;
|
|
12
|
+
readonly getBytes: () => Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export type LatchedDefaultWasmSource = {
|
|
15
|
+
readonly kind: "embedded";
|
|
16
|
+
readonly bytes: Uint8Array;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "url";
|
|
19
|
+
};
|
|
20
|
+
export declare function getEmbeddedWasmCompatId(solver: EmbeddedWasmSolver): string;
|
|
21
|
+
export declare function getEmbeddedWasmSymbolKey(solver: EmbeddedWasmSolver): symbol;
|
|
22
|
+
/**
|
|
23
|
+
* Selects and permanently latches the default WASM source ("embedded" or "url") on first use.
|
|
24
|
+
* Subsequent calls always return the latched choice even if an inline pack is loaded later.
|
|
25
|
+
*/
|
|
26
|
+
export declare function latchDefaultWasmSource(solver: EmbeddedWasmSolver): LatchedDefaultWasmSource;
|
|
27
|
+
/**
|
|
28
|
+
* Peeks at the already-latched default WASM source without triggering latching.
|
|
29
|
+
*/
|
|
30
|
+
export declare function peekLatchedDefaultWasmSource(solver: EmbeddedWasmSolver): LatchedDefaultWasmSource | null;
|
|
31
|
+
/**
|
|
32
|
+
* Binds embedded WASM bytes sent to a Web Worker when the Worker starts.
|
|
33
|
+
* No-ops if the Worker has already latched a default WASM source.
|
|
34
|
+
*/
|
|
35
|
+
export declare function bindWorkerEmbeddedWasm(solver: EmbeddedWasmSolver, rawBytes: unknown): void;
|
|
36
|
+
//# sourceMappingURL=embedded-wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded-wasm.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/embedded-wasm.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,8CAA8C,CAAC;AACzF,eAAO,MAAM,+BAA+B,4CAA4C,CAAC;AAEzF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,UAAU,CAAC;CACrC;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAO7B,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAE1E;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAE3E;AA2DD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,wBAAwB,CAU3F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,kBAAkB,GACzB,wBAAwB,GAAG,IAAI,CAEjC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAK1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/highs/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/highs/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAQvE,OAAO,EACL,KAAK,EAEL,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,2BAA2B,EAAE,KAAK,EAAE,CAAC;AA4BnF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,IAAI,CAuE3F;AAOD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,QAMjD;AAED,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAQ5D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASjF;AAuCD;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhF;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAkEjF;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,GAAG,KAAK,CAAC;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACzC;AAID;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,YAAY,GAAG;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACtD,GACL,OAAO,CAAC;IAAE,MAAM,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAsb3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/highs/node-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,wBAAsB,aAAa,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"node-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/highs/node-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,wBAAsB,aAAa,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,CAoChF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/highs/worker-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/highs/worker-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAML,KAAK,mBAAmB,EAGzB,MAAM,aAAa,CAAC;AAqWrB;;;GAGG;AACH,wBAAsB,aAAa,CACjC,OAAO,GAAE,YAAY,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,OAAO,CAAC,OAAO,CAAC,CAYlB;AA4BD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,GAAE,YAAY,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CA2E9B;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,YAAY,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,OAAO,CAAC;IAAE,MAAM,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyD3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-pack.d.ts","sourceRoot":"","sources":["../../../../src/modeler/solvers/inline-pack.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC"}
|
|
@@ -26,7 +26,7 @@ export declare function resolvePumpkinWasmUrl(): string;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function resetPumpkinLoader(): void;
|
|
28
28
|
/**
|
|
29
|
-
* Returns `true` when an instantiated main-thread Pumpkin WASM runtime is cached for the resolved
|
|
29
|
+
* Returns `true` when an instantiated main-thread Pumpkin WASM runtime is cached for the resolved target.
|
|
30
30
|
*/
|
|
31
31
|
export declare function isPumpkinRuntimeCached(overrideWasmUrl?: string | null): boolean;
|
|
32
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/loader.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,cAAc;IAC7B,mBAAmB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC;IAC7F,mBAAmB,EAAE,CACnB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,IAAI,EACpD,YAAY,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,IAAI,KAClC,MAAM,CAAC;IACZ,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9C;AASD,iGAAiG;AACjG,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAE9E;AAUD,4DAA4D;AAC5D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAQ5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAc1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAKzC;AAiCD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAG/E;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAmBzC;AAyFD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,CAsDjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solver.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/solver.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"solver.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/solver.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,MAAM,aAAa,CAAC;AAizBrB;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,MAAM;IAC1C,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAQ9C;IAEF,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAA8B;IAEvE,YAAY,OAAO,GAAE,aAAkB,EAEtC;IAEK,KAAK,CACT,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAuF5B;IAEK,KAAK,CACT,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAkKvB;CACF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,CAAC,EAAE,aAAa,GAAG,IAAI,CAE1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/worker-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/worker-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../../src/modeler/solvers/pumpkin/worker.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,kBAAkB,CAAC,EAAE,UAAU,CAAC;CACjC"}
|
|
@@ -62,7 +62,9 @@ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bu
|
|
|
62
62
|
| --- | --- | --- |
|
|
63
63
|
| **Core (HiGHS & Pumpkin)** | `import { Model, expr, maximize } from "./washi/washi.js";` | `<script src="./washi/washi.min.js"></script>` (global `Washi`) |
|
|
64
64
|
| **HiGHS** *(subpath API)* | `import { HighsSolver, setHighsWasmUrl } from "./washi/solvers/highs.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
|
|
65
|
+
| **HiGHS Inline WASM** *(no `fetch`)* | `import "./washi/solvers/highs-inline.js";` | `<script src="./washi/solvers/highs-inline.js"></script>` (`@ohtaman/washi/browser/solvers/highs-inline`) |
|
|
65
66
|
| **Pumpkin** *(subpath API)* | `import { PumpkinSolver, setPumpkinWasmUrl } from "./washi/solvers/pumpkin.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
|
|
67
|
+
| **Pumpkin Inline WASM** *(no `fetch`)* | `import "./washi/solvers/pumpkin-inline.js";` | `<script src="./washi/solvers/pumpkin-inline.js"></script>` (`@ohtaman/washi/browser/solvers/pumpkin-inline`) |
|
|
66
68
|
| **GLPK** *(optional)* | `import "./washi/solvers/glpk.js";` | `<script src="./washi/solvers/glpk.min.js"></script>` (`WashiGLPK`) |
|
|
67
69
|
| **Z3** *(optional)* | `import "./washi/solvers/z3.js";` | `<script src="./washi/solvers/z3.min.js"></script>` (`WashiZ3`) |
|
|
68
70
|
|
|
@@ -74,6 +76,44 @@ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bu
|
|
|
74
76
|
- **Browser self-hosting**: Deploy `dist/browser/` intact (entry scripts, `solvers/` runtime/worker/WASM assets, and chunks). Requests that hit missing URLs or HTML SPA fallbacks fail immediately and report the attempted URL.
|
|
75
77
|
- **Custom browser URLs**: Call `setHighsWasmUrl(url)` (from `@ohtaman/washi/solvers/highs`) or `setPumpkinWasmUrl(url)` (from `@ohtaman/washi/solvers/pumpkin`), or pass `{ wasmUrl }` to `m.solve()` / `m.check()`. This override is ignored for HiGHS in Node.js, while Pumpkin accepts `file://` URLs in Node.js. For Z3, call `setZ3Assets({ jsUrl, wasmUrl })` (from `@ohtaman/washi/solvers/z3`) or pass `{ z3JsUrl, z3WasmUrl }`.
|
|
76
78
|
|
|
79
|
+
#### Fetch-Free Loading in CSP-Restricted Pages (Inline WASM)
|
|
80
|
+
|
|
81
|
+
- **When `fetch()` is blocked (`connect-src 'none'`)**: Hosted single-file HTML environments (such as published Claude.ai artifacts or restricted HTML previews) may permit CDN scripts (`script-src`) while blocking `fetch()` via `connect-src`. Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtaman/washi/browser/solvers/highs-inline` and `solvers/pumpkin-inline.js` / `@ohtaman/washi/browser/solvers/pumpkin-inline`), then solve using the ordinary modeling API with zero base64 or binary-setter boilerplate.
|
|
82
|
+
- **Dual ESM & Classic `<script>` support**: Each `*-inline.js` file has no `import`/`export` statements, so the exact same file works via ESM `import` and classic `<script src="...">`. Default loaders (`washi.js`, `washi.min.js`, `dist/lib/*`) never reference `*-inline.js`, so ordinary bundler and Node.js users pay zero extra bundle size.
|
|
83
|
+
- **Initialization semantics**: Load the inline pack **before** the first solver initialization (`solve()`, `check()`, or `warmup*()`). Before first initialization, load order between core (`washi.js` / `washi.min.js`) and `*-inline.js` does not matter. Once a solver's default WASM source is selected on first initialization, WaSHI latches it and does not switch on late pack loads (keeping main-thread and Worker behavior consistent). Explicit `set*WasmUrl()` / `{ wasmUrl }` still override the embedded pack when provided.
|
|
84
|
+
- **Worker behavior**: Under `useWorker: true`, WaSHI sends the embedded bytes once to the Worker via `postMessage` so Worker startup does not call `fetch()`. If `worker-src` disallows Workers or `blob:` URLs, pass `{ useWorker: false }` (runs on the main thread with zero external `.wasm` fetches, zero `blob:` URLs, and zero Workers).
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<!-- ESM (e.g. Claude.ai artifacts) -->
|
|
88
|
+
<script type="module">
|
|
89
|
+
import { Model, expr, maximize } from "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.js";
|
|
90
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js";
|
|
91
|
+
// import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js";
|
|
92
|
+
|
|
93
|
+
const m = new Model("CspFreeEsm");
|
|
94
|
+
const x = m.integer("x", { lb: 0 });
|
|
95
|
+
m.objective(maximize(x));
|
|
96
|
+
m.constraint(expr`${x} <= 10`, "cap");
|
|
97
|
+
await m.solve(); // Pass { useWorker: false } if Workers or blob: URLs are blocked
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<!-- Classic <script> (restricted HTML previews without ESM or Workers) -->
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.min.js"></script>
|
|
102
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js"></script>
|
|
103
|
+
<script>
|
|
104
|
+
(async () => {
|
|
105
|
+
const { Model, expr, maximize } = Washi;
|
|
106
|
+
const m = new Model("CspFreeClassic");
|
|
107
|
+
const x = m.integer("x", { lb: 0 });
|
|
108
|
+
m.objective(maximize(x));
|
|
109
|
+
m.constraint(expr`${x} <= 10`, "cap");
|
|
110
|
+
await m.solve({ useWorker: false });
|
|
111
|
+
})();
|
|
112
|
+
</script>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> **Single-file offline HTML (`file://` with npm packages)**: Use the CDN `*-inline.js` packs above for zero-build hosted CSP sandboxes (`connect-src 'none'`, such as published Claude.ai artifacts or restricted HTML previews). When building a zero-network, double-clickable offline `file://` HTML app that bundles `@ohtaman/washi` (HiGHS / Pumpkin) together with third-party npm packages (React, KaTeX, Chart.js, Tailwind) via Vite + `vite-plugin-singlefile` and gzipped WASM, follow the **`washi-single-html`** skill (`skills/washi-single-html/SKILL.md`).
|
|
116
|
+
|
|
77
117
|
#### Browser Security & Cross-Origin Isolation
|
|
78
118
|
|
|
79
119
|
- **HiGHS, Pumpkin, and GLPK**: Run in standard browser contexts without `SharedArrayBuffer` or isolation headers.
|
|
@@ -178,7 +218,7 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
|
|
|
178
218
|
- **Return value**: Returns `SolverStatus` (`"Optimal"`, `"Feasible"`, `"Infeasible"`, `"Unbounded"`, `"TimeLimit"`, `"IterationLimit"`, `"Error"`, `"Unknown"`, `"NotSolved"`, `"Sat"`, or `"Unsat"`).
|
|
179
219
|
- **Status semantics**: Optimization solvers return `"Feasible"` when a limit or abort terminates the solve with a valid primal incumbent. `"Sat"` and `"Unsat"` apply to satisfiability or custom solver adapters.
|
|
180
220
|
- **Reading results**: Check `m.hasPrimalSolution`, then read `x.value`, `` expr`...`.value ``, `m.objectiveValue`, `constr.dual`, `constr.slack`, and `x.reducedCost`. `m.values` (like `m.variables` and `m.constraints`) is a `ReadonlyMap<string, number | boolean>` (use `.get(name)`), unlike `CheckResult.values` and `m.solution.values` (`Record`).
|
|
181
|
-
- **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`.
|
|
221
|
+
- **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`. On decomposed models, `master.verify()` checks only the master model's constraints and integrality, so end-to-end invariants outside the master (such as TSP single-tour connectivity or full subproblem demand satisfaction) still require domain assertions.
|
|
182
222
|
|
|
183
223
|
#### Satisfiability & Conflict Diagnosis (`await m.check(options?)`)
|
|
184
224
|
|
|
@@ -191,6 +231,20 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
|
|
|
191
231
|
|
|
192
232
|
- Mutating variables, constraints, or the objective while an `m.solve()` or `m.check()` call is pending invalidates the in-flight run and rejects the stale promise.
|
|
193
233
|
|
|
234
|
+
### Decomposition APIs (Column Generation & Benders)
|
|
235
|
+
|
|
236
|
+
For full examples, see [`docs/guide/decomposition.md`](https://github.com/ohtaman/washi/blob/main/docs/guide/decomposition.md). `master.solveColumnGeneration(...)`, `m.relax()`, and `master.solveBenders(...)` auto-cut `sub.link(...)` mode require an LP-dual solver (**HiGHS** or **GLPK**; `Pumpkin` and `Z3` do not support LP duals or `relax: true`); manual `BendersCut` mode only calls `master.solve()`. Both helpers are also exported standalone.
|
|
237
|
+
|
|
238
|
+
- **Column Generation**: `await master.solveColumnGeneration({ pricing, finalizeAsMIP?, reducedCostTolerance?, maxIterations?, solver?, solverOptions?, onIteration? })`
|
|
239
|
+
- `pricing` receives `{ duals, getDual, iteration, master, masterSolution, reducedCostTolerance }` and returns `ColumnProposal | ColumnProposal[] | null`.
|
|
240
|
+
- Reduced cost (`cost - sum(pi_i * a_i)`) is computed and filtered automatically when `proposal.reducedCost` is omitted; `proposal.type` defaults to `"Continuous"`.
|
|
241
|
+
- Initial RMP LP relaxation must be feasible and bounded (no Phase-I artificials); `finalizeAsMIP: true` (default) runs a root-node Price-and-Branch heuristic rather than exact Branch-and-Price.
|
|
242
|
+
- **Benders Decomposition**: `await master.solveBenders({ subproblem, theta?, gapTolerance?, maxIterations?, solver?, solverOptions?, onIteration? })`
|
|
243
|
+
- `subproblem` receives `{ iteration, masterValues, getMasterValue, masterObjective, lowerBound, upperBound, master }` and returns either a continuous LP `Model` using `sub.link(constraint)` (optimality cuts only; throws on infeasible subproblem) or manual `BendersCut | BendersCut[] | null` (`{ kind: "optimality" | "feasibility", constraint, name?, subproblemObjective? }`).
|
|
244
|
+
- Auto-`theta` assumes a `Minimize` master with `lb: 0`; for `Maximize` or negative subproblem costs, declare `theta` on `master`, include it in `master.objective(...)`, and pass `{ theta }`.
|
|
245
|
+
- Manual `BendersCut.subproblemObjective` expects **Stage-1 direct cost (excluding `theta`) + Stage-2 cost**, not Stage-2 subproblem cost alone.
|
|
246
|
+
- **Low-level primitives**: `await m.relax()`, `c.dual` / `m.solution?.duals[name]`, `m.column({ cost, coefficients, type?, lb?, ub?, name? })`, and `c.addTerm(v, coeff)` / `c.setTerm(v, coeff)`.
|
|
247
|
+
|
|
194
248
|
---
|
|
195
249
|
|
|
196
250
|
## 3. Executable Examples
|
|
@@ -254,6 +254,7 @@ On standard `http://` and `https://` origins, browsers block direct `new Worker(
|
|
|
254
254
|
| **CDN scripts** | Loading `washi.min.js` from an HTTPS CDN includes both HiGHS and Pumpkin and works by double-clicking a local `.html` file (`file://`) with no local server. |
|
|
255
255
|
| **Opaque origins (`window.origin === "null"`)** | On `file://` pages or sandboxed `<iframe>` embeds without `allow-same-origin`, WaSHI runs HiGHS and Pumpkin on the main thread when `useWorker` is omitted. |
|
|
256
256
|
| **Self-hosted `.wasm` & Z3** | Local `.wasm` files require `http://` or `https://` because browsers block `fetch()` on `file://`. Z3 also requires Cross-Origin Isolation (see below). |
|
|
257
|
+
| **Offline single-file HTML + npm libs (`washi-single-html`)** | To bundle `@ohtaman/washi` (HiGHS & Pumpkin) alongside third-party npm packages into one zero-network `index.html` for `file://`, follow the **`washi-single-html`** skill (`skills/washi-single-html/SKILL.md`). |
|
|
257
258
|
|
|
258
259
|
---
|
|
259
260
|
|
|
@@ -281,6 +282,50 @@ Copy `node_modules/@ohtaman/washi/dist/browser/` to your static origin as a comp
|
|
|
281
282
|
| `worker-src` | `'self' blob:` | Allows default Web Workers and CDN `Blob` worker bootstraps. |
|
|
282
283
|
| `worker-src` (if `blob:` is disallowed) | `'self'` only | Serve `solvers/highs-worker.js` / `solvers/pumpkin-worker.js` from `'self'`, or pass `{ useWorker: false }`. |
|
|
283
284
|
|
|
284
|
-
### 3.
|
|
285
|
+
### 3. CSP-Restricted Pages Without `fetch()` (`connect-src 'none'`) {#csp-fetch-free}
|
|
286
|
+
|
|
287
|
+
Some hosted single-file HTML environments (such as published Claude.ai artifacts or restricted HTML previews) allow scripts from a CDN (`script-src`) while blocking `fetch()` via `connect-src 'none'`. In that environment, default HiGHS and Pumpkin initialization fails because they fetch `.wasm` files.
|
|
288
|
+
|
|
289
|
+
Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtaman/washi/browser/solvers/highs-inline` and `solvers/pumpkin-inline.js` / `@ohtaman/washi/browser/solvers/pumpkin-inline`) **before** your first `solve()`, `check()`, or `warmup*()` call—no manual base64 decoding or binary setter calls are required. Each inline pack contains no `import` or `export` statements, so the exact same file works in both ESM and classic `<script>` mode, and default loaders never reference it:
|
|
290
|
+
|
|
291
|
+
```html
|
|
292
|
+
<!-- Option A: ESM (<script type="module">) -->
|
|
293
|
+
<script type="module">
|
|
294
|
+
import { Model, expr, maximize } from "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.js";
|
|
295
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js";
|
|
296
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js";
|
|
297
|
+
|
|
298
|
+
const m = new Model("CspFreeExample");
|
|
299
|
+
const x = m.integer("x", { lb: 0 });
|
|
300
|
+
const y = m.integer("y", { lb: 0 });
|
|
301
|
+
m.objective(maximize(expr`30 * ${x} + 50 * ${y}`));
|
|
302
|
+
m.constraint(expr`${x} + 2 * ${y} <= 40`);
|
|
303
|
+
m.constraint(expr`2 * ${x} + ${y} <= 50`);
|
|
304
|
+
await m.solve(); // Works in main-thread and Web Worker mode without fetch()
|
|
305
|
+
</script>
|
|
306
|
+
|
|
307
|
+
<!-- Option B: Classic <script> (works even with worker-src 'none' when useWorker: false) -->
|
|
308
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.min.js"></script>
|
|
309
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js"></script>
|
|
310
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js"></script>
|
|
311
|
+
<script>
|
|
312
|
+
(async () => {
|
|
313
|
+
const { Model, expr, maximize } = Washi;
|
|
314
|
+
const m = new Model("CspFreeClassic");
|
|
315
|
+
const x = m.integer("x", { lb: 0 });
|
|
316
|
+
const y = m.integer("y", { lb: 0 });
|
|
317
|
+
m.objective(maximize(expr`30 * ${x} + 50 * ${y}`));
|
|
318
|
+
m.constraint(expr`${x} + 2 * ${y} <= 40`);
|
|
319
|
+
m.constraint(expr`2 * ${x} + ${y} <= 50`);
|
|
320
|
+
await m.solve({ useWorker: false }); // Zero fetch(), zero Blob URLs, zero Workers
|
|
321
|
+
})();
|
|
322
|
+
</script>
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
- **Initialization semantics**: Load `*-inline.js` before the first solver initialization (`solve()`, `check()`, or `warmup*()`). Load order between core (`washi.js` / `washi.min.js`) and `*-inline.js` does not matter before first initialization. Once a solver's default WASM source is selected on first initialization, WaSHI latches it and ignores late pack registration so main-thread and Worker behavior stay consistent.
|
|
326
|
+
- **Web Worker mode**: When `useWorker: true`, WaSHI transfers the embedded bytes once per Worker instance via `postMessage` so Worker startup does not call `fetch()`. If `worker-src` blocks `blob:` or Workers, pass `{ useWorker: false }`.
|
|
327
|
+
- **GLPK & Z3**: **GLPK** (`solvers/glpk.js`) already embeds its WASM inline without `fetch()`. **Z3** requires `SharedArrayBuffer` and Cross-Origin Isolation headers (below).
|
|
328
|
+
|
|
329
|
+
### 4. Enable Cross-Origin Isolation (Z3 Only)
|
|
285
330
|
|
|
286
331
|
HiGHS, Pumpkin, and GLPK run in standard browser contexts without isolation headers. Z3 uses `SharedArrayBuffer` multithreading, so browsers require a **Secure Context** (`https://` or `http://localhost`). You must also serve `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` headers (`COOP`/`COEP`); see the [Cross-Origin Isolation Guide](./cross-origin.md).
|
package/docs/solvers/highs.md
CHANGED
|
@@ -176,6 +176,8 @@ const syncModel = new Model({
|
|
|
176
176
|
|
|
177
177
|
If `highs.wasm` fails to load or returns an HTML error page, WaSHI throws an error with the attempted URL instead of silently falling back to an external CDN.
|
|
178
178
|
|
|
179
|
+
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/browser/solvers/highs-inline` / `solvers/highs-inline.js`, usable via ESM `import` or a classic `<script>` tag) before the first `solve()` or `warmupHighs()` call—this works in both main-thread and Web Worker mode without `fetch()` (pass `{ useWorker: false }` if Workers/`blob:` are blocked). See [Runtime Environments & Deployment](../getting-started/runtimes.md#csp-fetch-free).
|
|
180
|
+
|
|
179
181
|
---
|
|
180
182
|
|
|
181
183
|
## Architecture & WebAssembly Runtime
|
package/docs/solvers/pumpkin.md
CHANGED
|
@@ -163,6 +163,8 @@ const syncModel = new Model({ solver: new PumpkinSolver({ useWorker: false }) })
|
|
|
163
163
|
|
|
164
164
|
If `pumpkin.wasm` fails to load or returns an HTML fallback page, WaSHI throws an error with the attempted URL instead of silently falling back to a CDN.
|
|
165
165
|
|
|
166
|
+
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/browser/solvers/pumpkin-inline` / `solvers/pumpkin-inline.js`, usable via ESM `import` or a classic `<script>` tag) before the first `solve()`, `check()`, or `warmupPumpkin()` call—this works in both main-thread and Web Worker mode without `fetch()` (pass `{ useWorker: false }` if Workers/`blob:` are blocked). See [Runtime Environments & Deployment](../getting-started/runtimes.md#csp-fetch-free).
|
|
167
|
+
|
|
166
168
|
---
|
|
167
169
|
|
|
168
170
|
## References
|
package/llms-full.txt
CHANGED
|
@@ -62,7 +62,9 @@ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bu
|
|
|
62
62
|
| --- | --- | --- |
|
|
63
63
|
| **Core (HiGHS & Pumpkin)** | `import { Model, expr, maximize } from "./washi/washi.js";` | `<script src="./washi/washi.min.js"></script>` (global `Washi`) |
|
|
64
64
|
| **HiGHS** *(subpath API)* | `import { HighsSolver, setHighsWasmUrl } from "./washi/solvers/highs.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
|
|
65
|
+
| **HiGHS Inline WASM** *(no `fetch`)* | `import "./washi/solvers/highs-inline.js";` | `<script src="./washi/solvers/highs-inline.js"></script>` (`@ohtaman/washi/browser/solvers/highs-inline`) |
|
|
65
66
|
| **Pumpkin** *(subpath API)* | `import { PumpkinSolver, setPumpkinWasmUrl } from "./washi/solvers/pumpkin.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
|
|
67
|
+
| **Pumpkin Inline WASM** *(no `fetch`)* | `import "./washi/solvers/pumpkin-inline.js";` | `<script src="./washi/solvers/pumpkin-inline.js"></script>` (`@ohtaman/washi/browser/solvers/pumpkin-inline`) |
|
|
66
68
|
| **GLPK** *(optional)* | `import "./washi/solvers/glpk.js";` | `<script src="./washi/solvers/glpk.min.js"></script>` (`WashiGLPK`) |
|
|
67
69
|
| **Z3** *(optional)* | `import "./washi/solvers/z3.js";` | `<script src="./washi/solvers/z3.min.js"></script>` (`WashiZ3`) |
|
|
68
70
|
|
|
@@ -74,6 +76,44 @@ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bu
|
|
|
74
76
|
- **Browser self-hosting**: Deploy `dist/browser/` intact (entry scripts, `solvers/` runtime/worker/WASM assets, and chunks). Requests that hit missing URLs or HTML SPA fallbacks fail immediately and report the attempted URL.
|
|
75
77
|
- **Custom browser URLs**: Call `setHighsWasmUrl(url)` (from `@ohtaman/washi/solvers/highs`) or `setPumpkinWasmUrl(url)` (from `@ohtaman/washi/solvers/pumpkin`), or pass `{ wasmUrl }` to `m.solve()` / `m.check()`. This override is ignored for HiGHS in Node.js, while Pumpkin accepts `file://` URLs in Node.js. For Z3, call `setZ3Assets({ jsUrl, wasmUrl })` (from `@ohtaman/washi/solvers/z3`) or pass `{ z3JsUrl, z3WasmUrl }`.
|
|
76
78
|
|
|
79
|
+
#### Fetch-Free Loading in CSP-Restricted Pages (Inline WASM)
|
|
80
|
+
|
|
81
|
+
- **When `fetch()` is blocked (`connect-src 'none'`)**: Hosted single-file HTML environments (such as published Claude.ai artifacts or restricted HTML previews) may permit CDN scripts (`script-src`) while blocking `fetch()` via `connect-src`. Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtaman/washi/browser/solvers/highs-inline` and `solvers/pumpkin-inline.js` / `@ohtaman/washi/browser/solvers/pumpkin-inline`), then solve using the ordinary modeling API with zero base64 or binary-setter boilerplate.
|
|
82
|
+
- **Dual ESM & Classic `<script>` support**: Each `*-inline.js` file has no `import`/`export` statements, so the exact same file works via ESM `import` and classic `<script src="...">`. Default loaders (`washi.js`, `washi.min.js`, `dist/lib/*`) never reference `*-inline.js`, so ordinary bundler and Node.js users pay zero extra bundle size.
|
|
83
|
+
- **Initialization semantics**: Load the inline pack **before** the first solver initialization (`solve()`, `check()`, or `warmup*()`). Before first initialization, load order between core (`washi.js` / `washi.min.js`) and `*-inline.js` does not matter. Once a solver's default WASM source is selected on first initialization, WaSHI latches it and does not switch on late pack loads (keeping main-thread and Worker behavior consistent). Explicit `set*WasmUrl()` / `{ wasmUrl }` still override the embedded pack when provided.
|
|
84
|
+
- **Worker behavior**: Under `useWorker: true`, WaSHI sends the embedded bytes once to the Worker via `postMessage` so Worker startup does not call `fetch()`. If `worker-src` disallows Workers or `blob:` URLs, pass `{ useWorker: false }` (runs on the main thread with zero external `.wasm` fetches, zero `blob:` URLs, and zero Workers).
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<!-- ESM (e.g. Claude.ai artifacts) -->
|
|
88
|
+
<script type="module">
|
|
89
|
+
import { Model, expr, maximize } from "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.js";
|
|
90
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js";
|
|
91
|
+
// import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js";
|
|
92
|
+
|
|
93
|
+
const m = new Model("CspFreeEsm");
|
|
94
|
+
const x = m.integer("x", { lb: 0 });
|
|
95
|
+
m.objective(maximize(x));
|
|
96
|
+
m.constraint(expr`${x} <= 10`, "cap");
|
|
97
|
+
await m.solve(); // Pass { useWorker: false } if Workers or blob: URLs are blocked
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<!-- Classic <script> (restricted HTML previews without ESM or Workers) -->
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.min.js"></script>
|
|
102
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js"></script>
|
|
103
|
+
<script>
|
|
104
|
+
(async () => {
|
|
105
|
+
const { Model, expr, maximize } = Washi;
|
|
106
|
+
const m = new Model("CspFreeClassic");
|
|
107
|
+
const x = m.integer("x", { lb: 0 });
|
|
108
|
+
m.objective(maximize(x));
|
|
109
|
+
m.constraint(expr`${x} <= 10`, "cap");
|
|
110
|
+
await m.solve({ useWorker: false });
|
|
111
|
+
})();
|
|
112
|
+
</script>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> **Single-file offline HTML (`file://` with npm packages)**: Use the CDN `*-inline.js` packs above for zero-build hosted CSP sandboxes (`connect-src 'none'`, such as published Claude.ai artifacts or restricted HTML previews). When building a zero-network, double-clickable offline `file://` HTML app that bundles `@ohtaman/washi` (HiGHS / Pumpkin) together with third-party npm packages (React, KaTeX, Chart.js, Tailwind) via Vite + `vite-plugin-singlefile` and gzipped WASM, follow the **`washi-single-html`** skill (`skills/washi-single-html/SKILL.md`).
|
|
116
|
+
|
|
77
117
|
#### Browser Security & Cross-Origin Isolation
|
|
78
118
|
|
|
79
119
|
- **HiGHS, Pumpkin, and GLPK**: Run in standard browser contexts without `SharedArrayBuffer` or isolation headers.
|
|
@@ -178,7 +218,7 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
|
|
|
178
218
|
- **Return value**: Returns `SolverStatus` (`"Optimal"`, `"Feasible"`, `"Infeasible"`, `"Unbounded"`, `"TimeLimit"`, `"IterationLimit"`, `"Error"`, `"Unknown"`, `"NotSolved"`, `"Sat"`, or `"Unsat"`).
|
|
179
219
|
- **Status semantics**: Optimization solvers return `"Feasible"` when a limit or abort terminates the solve with a valid primal incumbent. `"Sat"` and `"Unsat"` apply to satisfiability or custom solver adapters.
|
|
180
220
|
- **Reading results**: Check `m.hasPrimalSolution`, then read `x.value`, `` expr`...`.value ``, `m.objectiveValue`, `constr.dual`, `constr.slack`, and `x.reducedCost`. `m.values` (like `m.variables` and `m.constraints`) is a `ReadonlyMap<string, number | boolean>` (use `.get(name)`), unlike `CheckResult.values` and `m.solution.values` (`Record`).
|
|
181
|
-
- **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`.
|
|
221
|
+
- **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`. On decomposed models, `master.verify()` checks only the master model's constraints and integrality, so end-to-end invariants outside the master (such as TSP single-tour connectivity or full subproblem demand satisfaction) still require domain assertions.
|
|
182
222
|
|
|
183
223
|
#### Satisfiability & Conflict Diagnosis (`await m.check(options?)`)
|
|
184
224
|
|
|
@@ -191,6 +231,20 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
|
|
|
191
231
|
|
|
192
232
|
- Mutating variables, constraints, or the objective while an `m.solve()` or `m.check()` call is pending invalidates the in-flight run and rejects the stale promise.
|
|
193
233
|
|
|
234
|
+
### Decomposition APIs (Column Generation & Benders)
|
|
235
|
+
|
|
236
|
+
For full examples, see [`docs/guide/decomposition.md`](https://github.com/ohtaman/washi/blob/main/docs/guide/decomposition.md). `master.solveColumnGeneration(...)`, `m.relax()`, and `master.solveBenders(...)` auto-cut `sub.link(...)` mode require an LP-dual solver (**HiGHS** or **GLPK**; `Pumpkin` and `Z3` do not support LP duals or `relax: true`); manual `BendersCut` mode only calls `master.solve()`. Both helpers are also exported standalone.
|
|
237
|
+
|
|
238
|
+
- **Column Generation**: `await master.solveColumnGeneration({ pricing, finalizeAsMIP?, reducedCostTolerance?, maxIterations?, solver?, solverOptions?, onIteration? })`
|
|
239
|
+
- `pricing` receives `{ duals, getDual, iteration, master, masterSolution, reducedCostTolerance }` and returns `ColumnProposal | ColumnProposal[] | null`.
|
|
240
|
+
- Reduced cost (`cost - sum(pi_i * a_i)`) is computed and filtered automatically when `proposal.reducedCost` is omitted; `proposal.type` defaults to `"Continuous"`.
|
|
241
|
+
- Initial RMP LP relaxation must be feasible and bounded (no Phase-I artificials); `finalizeAsMIP: true` (default) runs a root-node Price-and-Branch heuristic rather than exact Branch-and-Price.
|
|
242
|
+
- **Benders Decomposition**: `await master.solveBenders({ subproblem, theta?, gapTolerance?, maxIterations?, solver?, solverOptions?, onIteration? })`
|
|
243
|
+
- `subproblem` receives `{ iteration, masterValues, getMasterValue, masterObjective, lowerBound, upperBound, master }` and returns either a continuous LP `Model` using `sub.link(constraint)` (optimality cuts only; throws on infeasible subproblem) or manual `BendersCut | BendersCut[] | null` (`{ kind: "optimality" | "feasibility", constraint, name?, subproblemObjective? }`).
|
|
244
|
+
- Auto-`theta` assumes a `Minimize` master with `lb: 0`; for `Maximize` or negative subproblem costs, declare `theta` on `master`, include it in `master.objective(...)`, and pass `{ theta }`.
|
|
245
|
+
- Manual `BendersCut.subproblemObjective` expects **Stage-1 direct cost (excluding `theta`) + Stage-2 cost**, not Stage-2 subproblem cost alone.
|
|
246
|
+
- **Low-level primitives**: `await m.relax()`, `c.dual` / `m.solution?.duals[name]`, `m.column({ cost, coefficients, type?, lb?, ub?, name? })`, and `c.addTerm(v, coeff)` / `c.setTerm(v, coeff)`.
|
|
247
|
+
|
|
194
248
|
---
|
|
195
249
|
|
|
196
250
|
## 3. Executable Examples
|
|
@@ -739,6 +793,7 @@ On standard `http://` and `https://` origins, browsers block direct `new Worker(
|
|
|
739
793
|
| **CDN scripts** | Loading `washi.min.js` from an HTTPS CDN includes both HiGHS and Pumpkin and works by double-clicking a local `.html` file (`file://`) with no local server. |
|
|
740
794
|
| **Opaque origins (`window.origin === "null"`)** | On `file://` pages or sandboxed `<iframe>` embeds without `allow-same-origin`, WaSHI runs HiGHS and Pumpkin on the main thread when `useWorker` is omitted. |
|
|
741
795
|
| **Self-hosted `.wasm` & Z3** | Local `.wasm` files require `http://` or `https://` because browsers block `fetch()` on `file://`. Z3 also requires Cross-Origin Isolation (see below). |
|
|
796
|
+
| **Offline single-file HTML + npm libs (`washi-single-html`)** | To bundle `@ohtaman/washi` (HiGHS & Pumpkin) alongside third-party npm packages into one zero-network `index.html` for `file://`, follow the **`washi-single-html`** skill (`skills/washi-single-html/SKILL.md`). |
|
|
742
797
|
|
|
743
798
|
---
|
|
744
799
|
|
|
@@ -766,7 +821,51 @@ Copy `node_modules/@ohtaman/washi/dist/browser/` to your static origin as a comp
|
|
|
766
821
|
| `worker-src` | `'self' blob:` | Allows default Web Workers and CDN `Blob` worker bootstraps. |
|
|
767
822
|
| `worker-src` (if `blob:` is disallowed) | `'self'` only | Serve `solvers/highs-worker.js` / `solvers/pumpkin-worker.js` from `'self'`, or pass `{ useWorker: false }`. |
|
|
768
823
|
|
|
769
|
-
### 3.
|
|
824
|
+
### 3. CSP-Restricted Pages Without `fetch()` (`connect-src 'none'`) {#csp-fetch-free}
|
|
825
|
+
|
|
826
|
+
Some hosted single-file HTML environments (such as published Claude.ai artifacts or restricted HTML previews) allow scripts from a CDN (`script-src`) while blocking `fetch()` via `connect-src 'none'`. In that environment, default HiGHS and Pumpkin initialization fails because they fetch `.wasm` files.
|
|
827
|
+
|
|
828
|
+
Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtaman/washi/browser/solvers/highs-inline` and `solvers/pumpkin-inline.js` / `@ohtaman/washi/browser/solvers/pumpkin-inline`) **before** your first `solve()`, `check()`, or `warmup*()` call—no manual base64 decoding or binary setter calls are required. Each inline pack contains no `import` or `export` statements, so the exact same file works in both ESM and classic `<script>` mode, and default loaders never reference it:
|
|
829
|
+
|
|
830
|
+
```html
|
|
831
|
+
<!-- Option A: ESM (<script type="module">) -->
|
|
832
|
+
<script type="module">
|
|
833
|
+
import { Model, expr, maximize } from "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.js";
|
|
834
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js";
|
|
835
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js";
|
|
836
|
+
|
|
837
|
+
const m = new Model("CspFreeExample");
|
|
838
|
+
const x = m.integer("x", { lb: 0 });
|
|
839
|
+
const y = m.integer("y", { lb: 0 });
|
|
840
|
+
m.objective(maximize(expr`30 * ${x} + 50 * ${y}`));
|
|
841
|
+
m.constraint(expr`${x} + 2 * ${y} <= 40`);
|
|
842
|
+
m.constraint(expr`2 * ${x} + ${y} <= 50`);
|
|
843
|
+
await m.solve(); // Works in main-thread and Web Worker mode without fetch()
|
|
844
|
+
</script>
|
|
845
|
+
|
|
846
|
+
<!-- Option B: Classic <script> (works even with worker-src 'none' when useWorker: false) -->
|
|
847
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.min.js"></script>
|
|
848
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js"></script>
|
|
849
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js"></script>
|
|
850
|
+
<script>
|
|
851
|
+
(async () => {
|
|
852
|
+
const { Model, expr, maximize } = Washi;
|
|
853
|
+
const m = new Model("CspFreeClassic");
|
|
854
|
+
const x = m.integer("x", { lb: 0 });
|
|
855
|
+
const y = m.integer("y", { lb: 0 });
|
|
856
|
+
m.objective(maximize(expr`30 * ${x} + 50 * ${y}`));
|
|
857
|
+
m.constraint(expr`${x} + 2 * ${y} <= 40`);
|
|
858
|
+
m.constraint(expr`2 * ${x} + ${y} <= 50`);
|
|
859
|
+
await m.solve({ useWorker: false }); // Zero fetch(), zero Blob URLs, zero Workers
|
|
860
|
+
})();
|
|
861
|
+
</script>
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
- **Initialization semantics**: Load `*-inline.js` before the first solver initialization (`solve()`, `check()`, or `warmup*()`). Load order between core (`washi.js` / `washi.min.js`) and `*-inline.js` does not matter before first initialization. Once a solver's default WASM source is selected on first initialization, WaSHI latches it and ignores late pack registration so main-thread and Worker behavior stay consistent.
|
|
865
|
+
- **Web Worker mode**: When `useWorker: true`, WaSHI transfers the embedded bytes once per Worker instance via `postMessage` so Worker startup does not call `fetch()`. If `worker-src` blocks `blob:` or Workers, pass `{ useWorker: false }`.
|
|
866
|
+
- **GLPK & Z3**: **GLPK** (`solvers/glpk.js`) already embeds its WASM inline without `fetch()`. **Z3** requires `SharedArrayBuffer` and Cross-Origin Isolation headers (below).
|
|
867
|
+
|
|
868
|
+
### 4. Enable Cross-Origin Isolation (Z3 Only)
|
|
770
869
|
|
|
771
870
|
HiGHS, Pumpkin, and GLPK run in standard browser contexts without isolation headers. Z3 uses `SharedArrayBuffer` multithreading, so browsers require a **Secure Context** (`https://` or `http://localhost`). You must also serve `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` headers (`COOP`/`COEP`); see the [Cross-Origin Isolation Guide](docs/getting-started/cross-origin.md).
|
|
772
871
|
|
|
@@ -3052,6 +3151,8 @@ const syncModel = new Model({
|
|
|
3052
3151
|
|
|
3053
3152
|
If `highs.wasm` fails to load or returns an HTML error page, WaSHI throws an error with the attempted URL instead of silently falling back to an external CDN.
|
|
3054
3153
|
|
|
3154
|
+
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/browser/solvers/highs-inline` / `solvers/highs-inline.js`, usable via ESM `import` or a classic `<script>` tag) before the first `solve()` or `warmupHighs()` call—this works in both main-thread and Web Worker mode without `fetch()` (pass `{ useWorker: false }` if Workers/`blob:` are blocked). See [Runtime Environments & Deployment](docs/getting-started/runtimes.md#csp-fetch-free).
|
|
3155
|
+
|
|
3055
3156
|
---
|
|
3056
3157
|
|
|
3057
3158
|
## Architecture & WebAssembly Runtime
|
|
@@ -3245,6 +3346,8 @@ const syncModel = new Model({ solver: new PumpkinSolver({ useWorker: false }) })
|
|
|
3245
3346
|
|
|
3246
3347
|
If `pumpkin.wasm` fails to load or returns an HTML fallback page, WaSHI throws an error with the attempted URL instead of silently falling back to a CDN.
|
|
3247
3348
|
|
|
3349
|
+
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/browser/solvers/pumpkin-inline` / `solvers/pumpkin-inline.js`, usable via ESM `import` or a classic `<script>` tag) before the first `solve()`, `check()`, or `warmupPumpkin()` call—this works in both main-thread and Web Worker mode without `fetch()` (pass `{ useWorker: false }` if Workers/`blob:` are blocked). See [Runtime Environments & Deployment](docs/getting-started/runtimes.md#csp-fetch-free).
|
|
3350
|
+
|
|
3248
3351
|
---
|
|
3249
3352
|
|
|
3250
3353
|
## References
|
package/llms.txt
CHANGED
|
@@ -56,7 +56,9 @@ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bu
|
|
|
56
56
|
| --- | --- | --- |
|
|
57
57
|
| **Core (HiGHS & Pumpkin)** | `import { Model, expr, maximize } from "./washi/washi.js";` | `<script src="./washi/washi.min.js"></script>` (global `Washi`) |
|
|
58
58
|
| **HiGHS** *(subpath API)* | `import { HighsSolver, setHighsWasmUrl } from "./washi/solvers/highs.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
|
|
59
|
+
| **HiGHS Inline WASM** *(no `fetch`)* | `import "./washi/solvers/highs-inline.js";` | `<script src="./washi/solvers/highs-inline.js"></script>` (`@ohtaman/washi/browser/solvers/highs-inline`) |
|
|
59
60
|
| **Pumpkin** *(subpath API)* | `import { PumpkinSolver, setPumpkinWasmUrl } from "./washi/solvers/pumpkin.js";` | Bundled in `washi.min.js` (pass `{ wasmUrl }` per call) |
|
|
61
|
+
| **Pumpkin Inline WASM** *(no `fetch`)* | `import "./washi/solvers/pumpkin-inline.js";` | `<script src="./washi/solvers/pumpkin-inline.js"></script>` (`@ohtaman/washi/browser/solvers/pumpkin-inline`) |
|
|
60
62
|
| **GLPK** *(optional)* | `import "./washi/solvers/glpk.js";` | `<script src="./washi/solvers/glpk.min.js"></script>` (`WashiGLPK`) |
|
|
61
63
|
| **Z3** *(optional)* | `import "./washi/solvers/z3.js";` | `<script src="./washi/solvers/z3.min.js"></script>` (`WashiZ3`) |
|
|
62
64
|
|
|
@@ -68,6 +70,44 @@ Classic `<script>` tags load immediately invoked function expression (`IIFE`) bu
|
|
|
68
70
|
- **Browser self-hosting**: Deploy `dist/browser/` intact (entry scripts, `solvers/` runtime/worker/WASM assets, and chunks). Requests that hit missing URLs or HTML SPA fallbacks fail immediately and report the attempted URL.
|
|
69
71
|
- **Custom browser URLs**: Call `setHighsWasmUrl(url)` (from `@ohtaman/washi/solvers/highs`) or `setPumpkinWasmUrl(url)` (from `@ohtaman/washi/solvers/pumpkin`), or pass `{ wasmUrl }` to `m.solve()` / `m.check()`. This override is ignored for HiGHS in Node.js, while Pumpkin accepts `file://` URLs in Node.js. For Z3, call `setZ3Assets({ jsUrl, wasmUrl })` (from `@ohtaman/washi/solvers/z3`) or pass `{ z3JsUrl, z3WasmUrl }`.
|
|
70
72
|
|
|
73
|
+
#### Fetch-Free Loading in CSP-Restricted Pages (Inline WASM)
|
|
74
|
+
|
|
75
|
+
- **When `fetch()` is blocked (`connect-src 'none'`)**: Hosted single-file HTML environments (such as published Claude.ai artifacts or restricted HTML previews) may permit CDN scripts (`script-src`) while blocking `fetch()` via `connect-src`. Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtaman/washi/browser/solvers/highs-inline` and `solvers/pumpkin-inline.js` / `@ohtaman/washi/browser/solvers/pumpkin-inline`), then solve using the ordinary modeling API with zero base64 or binary-setter boilerplate.
|
|
76
|
+
- **Dual ESM & Classic `<script>` support**: Each `*-inline.js` file has no `import`/`export` statements, so the exact same file works via ESM `import` and classic `<script src="...">`. Default loaders (`washi.js`, `washi.min.js`, `dist/lib/*`) never reference `*-inline.js`, so ordinary bundler and Node.js users pay zero extra bundle size.
|
|
77
|
+
- **Initialization semantics**: Load the inline pack **before** the first solver initialization (`solve()`, `check()`, or `warmup*()`). Before first initialization, load order between core (`washi.js` / `washi.min.js`) and `*-inline.js` does not matter. Once a solver's default WASM source is selected on first initialization, WaSHI latches it and does not switch on late pack loads (keeping main-thread and Worker behavior consistent). Explicit `set*WasmUrl()` / `{ wasmUrl }` still override the embedded pack when provided.
|
|
78
|
+
- **Worker behavior**: Under `useWorker: true`, WaSHI sends the embedded bytes once to the Worker via `postMessage` so Worker startup does not call `fetch()`. If `worker-src` disallows Workers or `blob:` URLs, pass `{ useWorker: false }` (runs on the main thread with zero external `.wasm` fetches, zero `blob:` URLs, and zero Workers).
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<!-- ESM (e.g. Claude.ai artifacts) -->
|
|
82
|
+
<script type="module">
|
|
83
|
+
import { Model, expr, maximize } from "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.js";
|
|
84
|
+
import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js";
|
|
85
|
+
// import "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/pumpkin-inline.js";
|
|
86
|
+
|
|
87
|
+
const m = new Model("CspFreeEsm");
|
|
88
|
+
const x = m.integer("x", { lb: 0 });
|
|
89
|
+
m.objective(maximize(x));
|
|
90
|
+
m.constraint(expr`${x} <= 10`, "cap");
|
|
91
|
+
await m.solve(); // Pass { useWorker: false } if Workers or blob: URLs are blocked
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<!-- Classic <script> (restricted HTML previews without ESM or Workers) -->
|
|
95
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/washi.min.js"></script>
|
|
96
|
+
<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/browser/solvers/highs-inline.js"></script>
|
|
97
|
+
<script>
|
|
98
|
+
(async () => {
|
|
99
|
+
const { Model, expr, maximize } = Washi;
|
|
100
|
+
const m = new Model("CspFreeClassic");
|
|
101
|
+
const x = m.integer("x", { lb: 0 });
|
|
102
|
+
m.objective(maximize(x));
|
|
103
|
+
m.constraint(expr`${x} <= 10`, "cap");
|
|
104
|
+
await m.solve({ useWorker: false });
|
|
105
|
+
})();
|
|
106
|
+
</script>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
> **Single-file offline HTML (`file://` with npm packages)**: Use the CDN `*-inline.js` packs above for zero-build hosted CSP sandboxes (`connect-src 'none'`, such as published Claude.ai artifacts or restricted HTML previews). When building a zero-network, double-clickable offline `file://` HTML app that bundles `@ohtaman/washi` (HiGHS / Pumpkin) together with third-party npm packages (React, KaTeX, Chart.js, Tailwind) via Vite + `vite-plugin-singlefile` and gzipped WASM, follow the **`washi-single-html`** skill (`skills/washi-single-html/SKILL.md`).
|
|
110
|
+
|
|
71
111
|
#### Browser Security & Cross-Origin Isolation
|
|
72
112
|
|
|
73
113
|
- **HiGHS, Pumpkin, and GLPK**: Run in standard browser contexts without `SharedArrayBuffer` or isolation headers.
|
|
@@ -172,7 +212,7 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
|
|
|
172
212
|
- **Return value**: Returns `SolverStatus` (`"Optimal"`, `"Feasible"`, `"Infeasible"`, `"Unbounded"`, `"TimeLimit"`, `"IterationLimit"`, `"Error"`, `"Unknown"`, `"NotSolved"`, `"Sat"`, or `"Unsat"`).
|
|
173
213
|
- **Status semantics**: Optimization solvers return `"Feasible"` when a limit or abort terminates the solve with a valid primal incumbent. `"Sat"` and `"Unsat"` apply to satisfiability or custom solver adapters.
|
|
174
214
|
- **Reading results**: Check `m.hasPrimalSolution`, then read `x.value`, `` expr`...`.value ``, `m.objectiveValue`, `constr.dual`, `constr.slack`, and `x.reducedCost`. `m.values` (like `m.variables` and `m.constraints`) is a `ReadonlyMap<string, number | boolean>` (use `.get(name)`), unlike `CheckResult.values` and `m.solution.values` (`Record`).
|
|
175
|
-
- **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`.
|
|
215
|
+
- **Independent verification**: `m.verify()` checks primal feasibility—finiteness, bounds, integrality, and constraints—returning `VerificationReport` (`{ valid, complete, maxViolation, violations }`) without recomputing `m.objectiveValue`. On decomposed models, `master.verify()` checks only the master model's constraints and integrality, so end-to-end invariants outside the master (such as TSP single-tour connectivity or full subproblem demand satisfaction) still require domain assertions.
|
|
176
216
|
|
|
177
217
|
#### Satisfiability & Conflict Diagnosis (`await m.check(options?)`)
|
|
178
218
|
|
|
@@ -185,6 +225,20 @@ m.indicator(b, expr`${x} <= 50`, { activeValue: 1, name: "cap_when_b" });
|
|
|
185
225
|
|
|
186
226
|
- Mutating variables, constraints, or the objective while an `m.solve()` or `m.check()` call is pending invalidates the in-flight run and rejects the stale promise.
|
|
187
227
|
|
|
228
|
+
### Decomposition APIs (Column Generation & Benders)
|
|
229
|
+
|
|
230
|
+
For full examples, see [`docs/guide/decomposition.md`](https://github.com/ohtaman/washi/blob/main/docs/guide/decomposition.md). `master.solveColumnGeneration(...)`, `m.relax()`, and `master.solveBenders(...)` auto-cut `sub.link(...)` mode require an LP-dual solver (**HiGHS** or **GLPK**; `Pumpkin` and `Z3` do not support LP duals or `relax: true`); manual `BendersCut` mode only calls `master.solve()`. Both helpers are also exported standalone.
|
|
231
|
+
|
|
232
|
+
- **Column Generation**: `await master.solveColumnGeneration({ pricing, finalizeAsMIP?, reducedCostTolerance?, maxIterations?, solver?, solverOptions?, onIteration? })`
|
|
233
|
+
- `pricing` receives `{ duals, getDual, iteration, master, masterSolution, reducedCostTolerance }` and returns `ColumnProposal | ColumnProposal[] | null`.
|
|
234
|
+
- Reduced cost (`cost - sum(pi_i * a_i)`) is computed and filtered automatically when `proposal.reducedCost` is omitted; `proposal.type` defaults to `"Continuous"`.
|
|
235
|
+
- Initial RMP LP relaxation must be feasible and bounded (no Phase-I artificials); `finalizeAsMIP: true` (default) runs a root-node Price-and-Branch heuristic rather than exact Branch-and-Price.
|
|
236
|
+
- **Benders Decomposition**: `await master.solveBenders({ subproblem, theta?, gapTolerance?, maxIterations?, solver?, solverOptions?, onIteration? })`
|
|
237
|
+
- `subproblem` receives `{ iteration, masterValues, getMasterValue, masterObjective, lowerBound, upperBound, master }` and returns either a continuous LP `Model` using `sub.link(constraint)` (optimality cuts only; throws on infeasible subproblem) or manual `BendersCut | BendersCut[] | null` (`{ kind: "optimality" | "feasibility", constraint, name?, subproblemObjective? }`).
|
|
238
|
+
- Auto-`theta` assumes a `Minimize` master with `lb: 0`; for `Maximize` or negative subproblem costs, declare `theta` on `master`, include it in `master.objective(...)`, and pass `{ theta }`.
|
|
239
|
+
- Manual `BendersCut.subproblemObjective` expects **Stage-1 direct cost (excluding `theta`) + Stage-2 cost**, not Stage-2 subproblem cost alone.
|
|
240
|
+
- **Low-level primitives**: `await m.relax()`, `c.dual` / `m.solution?.duals[name]`, `m.column({ cost, coefficients, type?, lb?, ub?, name? })`, and `c.addTerm(v, coeff)` / `c.setTerm(v, coeff)`.
|
|
241
|
+
|
|
188
242
|
---
|
|
189
243
|
|
|
190
244
|
## 3. Common Pitfalls & Retired Aliases
|