diff-grok 1.1.0 → 1.2.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/.claude/skills/license-updater/SKILL.md +149 -0
- package/.claude/skills/license-updater/references/compatibility.md +68 -0
- package/.claude/skills/license-updater/references/templates.md +151 -0
- package/.claude/skills/license-updater/scripts/generate_license_files.py +467 -0
- package/CLAUDE.md +10 -4
- package/LICENSE +1 -1
- package/README.MD +41 -23
- package/THIRD_PARTY_LICENSES +135 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +99 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/BasicModelPipelineCreator.html +10 -0
- package/docs/classes/Callback.html +7 -0
- package/docs/classes/CyclicModelPipelineCreator.html +10 -0
- package/docs/classes/IterCheckerCallback.html +8 -0
- package/docs/classes/PipelineCreator.html +6 -0
- package/docs/classes/TimeCheckerCallback.html +8 -0
- package/docs/classes/UpdatesModelPipelineCreator.html +10 -0
- package/docs/functions/ab4.html +8 -0
- package/docs/functions/ab5.html +8 -0
- package/docs/functions/applyPipeline.html +9 -0
- package/docs/functions/getCallback.html +3 -0
- package/docs/functions/getIVP.html +6 -0
- package/docs/functions/getInputVector.html +2 -0
- package/docs/functions/getIvp2WebWorker.html +6 -0
- package/docs/functions/getJScode.html +6 -0
- package/docs/functions/getOutputNames.html +4 -0
- package/docs/functions/getPipelineCreator.html +7 -0
- package/docs/functions/lsoda.html +8 -0
- package/docs/functions/mrt.html +11 -0
- package/docs/functions/printE5.html +76 -0
- package/docs/functions/printHires.html +76 -0
- package/docs/functions/printOrego.html +66 -0
- package/docs/functions/printPollution.html +163 -0
- package/docs/functions/printRobertson.html +60 -0
- package/docs/functions/printVdpol.html +66 -0
- package/docs/functions/rk3.html +8 -0
- package/docs/functions/rk4.html +8 -0
- package/docs/functions/rkdp.html +8 -0
- package/docs/functions/ros34prw.html +8 -0
- package/docs/functions/ros3prw.html +8 -0
- package/docs/functions/solveIvp.html +5 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +768 -0
- package/docs/media/CONTRIBUTING.md +74 -0
- package/docs/media/E5.png +0 -0
- package/docs/media/HIRES.png +0 -0
- package/docs/media/OREGO.png +0 -0
- package/docs/media/POLL-full.png +0 -0
- package/docs/media/POLL.png +0 -0
- package/docs/media/ROBER.png +0 -0
- package/docs/media/VDP0L.png +0 -0
- package/docs/media/VDPOL.png +0 -0
- package/docs/media/acid-prod.gif +0 -0
- package/docs/media/basic-use.js +40 -0
- package/docs/media/basic-use.js.map +1 -0
- package/docs/media/basic-use.ts +44 -0
- package/docs/media/check-methods.js +59 -0
- package/docs/media/check-methods.js.map +1 -0
- package/docs/media/check-methods.ts +81 -0
- package/docs/media/corr-probs.js +132 -0
- package/docs/media/corr-probs.js.map +1 -0
- package/docs/media/corr-probs.ts +155 -0
- package/docs/media/cyclic-model.js +102 -0
- package/docs/media/cyclic-model.js.map +1 -0
- package/docs/media/cyclic-model.ts +112 -0
- package/docs/media/e5.js +36 -0
- package/docs/media/e5.js.map +1 -0
- package/docs/media/e5.ts +36 -0
- package/docs/media/hires.js +39 -0
- package/docs/media/hires.js.map +1 -0
- package/docs/media/hires.ts +40 -0
- package/docs/media/model-updates.js +112 -0
- package/docs/media/model-updates.js.map +1 -0
- package/docs/media/model-updates.ts +122 -0
- package/docs/media/orego.js +24 -0
- package/docs/media/orego.js.map +1 -0
- package/docs/media/orego.ts +25 -0
- package/docs/media/pipeline-use.js +87 -0
- package/docs/media/pipeline-use.js.map +1 -0
- package/docs/media/pipeline-use.ts +98 -0
- package/docs/media/pollution.js +132 -0
- package/docs/media/pollution.js.map +1 -0
- package/docs/media/pollution.ts +133 -0
- package/docs/media/print-benchmark.js +581 -0
- package/docs/media/print-benchmark.js.map +1 -0
- package/docs/media/print-benchmark.ts +594 -0
- package/docs/media/robertson.js +19 -0
- package/docs/media/robertson.js.map +1 -0
- package/docs/media/robertson.ts +19 -0
- package/docs/media/scripting.js +30 -0
- package/docs/media/scripting.js.map +1 -0
- package/docs/media/scripting.ts +35 -0
- package/docs/media/vdpol.js +17 -0
- package/docs/media/vdpol.js.map +1 -0
- package/docs/media/vdpol.ts +17 -0
- package/docs/modules.html +1 -0
- package/docs/types/Arg.html +12 -0
- package/docs/types/DifEqs.html +8 -0
- package/docs/types/Func.html +7 -0
- package/docs/types/IVP.html +40 -0
- package/docs/types/IVP2WebWorker.html +12 -0
- package/docs/types/Input.html +8 -0
- package/docs/types/Loop.html +7 -0
- package/docs/types/ODEs.html +31 -0
- package/docs/types/Output.html +6 -0
- package/docs/types/Pipeline.html +6 -0
- package/docs/types/SolverOptions.html +8 -0
- package/docs/types/Update.html +9 -0
- package/docs/types/Wrapper.html +8 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.ts +1 -1
- package/package.json +4 -2
- package/src/examples/check-methods.js +15 -3
- package/src/examples/check-methods.js.map +1 -1
- package/src/examples/check-methods.ts +18 -3
- package/src/solver-tools/cvode/common.js +487 -0
- package/src/solver-tools/cvode/common.js.map +1 -0
- package/src/solver-tools/cvode/common.ts +549 -0
- package/src/solver-tools/cvode/cvode.js +1062 -0
- package/src/solver-tools/cvode/cvode.js.map +1 -0
- package/src/solver-tools/cvode/cvode.ts +1226 -0
- package/src/solver-tools/cvode/cvode_adams.js +124 -0
- package/src/solver-tools/cvode/cvode_adams.js.map +1 -0
- package/src/solver-tools/cvode/cvode_adams.ts +142 -0
- package/src/solver-tools/cvode/cvode_bdf.js +153 -0
- package/src/solver-tools/cvode/cvode_bdf.js.map +1 -0
- package/src/solver-tools/cvode/cvode_bdf.ts +164 -0
- package/src/solver-tools/cvode/cvode_class.js +158 -0
- package/src/solver-tools/cvode/cvode_class.js.map +1 -0
- package/src/solver-tools/cvode/cvode_class.ts +271 -0
- package/src/solver-tools/cvode/cvode_hin.js +119 -0
- package/src/solver-tools/cvode/cvode_hin.js.map +1 -0
- package/src/solver-tools/cvode/cvode_hin.ts +150 -0
- package/src/solver-tools/cvode/cvode_io.js +203 -0
- package/src/solver-tools/cvode/cvode_io.js.map +1 -0
- package/src/solver-tools/cvode/cvode_io.ts +258 -0
- package/src/solver-tools/cvode/cvode_ls.js +210 -0
- package/src/solver-tools/cvode/cvode_ls.js.map +1 -0
- package/src/solver-tools/cvode/cvode_ls.ts +249 -0
- package/src/solver-tools/cvode/cvode_nls.js +220 -0
- package/src/solver-tools/cvode/cvode_nls.js.map +1 -0
- package/src/solver-tools/cvode/cvode_nls.ts +259 -0
- package/src/solver-tools/cvode/cvode_root.js +415 -0
- package/src/solver-tools/cvode/cvode_root.js.map +1 -0
- package/src/solver-tools/cvode/cvode_root.ts +503 -0
- package/src/solver-tools/cvode/dense_linalg.js +131 -0
- package/src/solver-tools/cvode/dense_linalg.js.map +1 -0
- package/src/solver-tools/cvode/dense_linalg.ts +144 -0
- package/src/solver-tools/cvode/index.js +26 -0
- package/src/solver-tools/cvode/index.js.map +1 -0
- package/src/solver-tools/cvode/index.ts +64 -0
- package/src/solver-tools/cvode-method.js +114 -0
- package/src/solver-tools/cvode-method.js.map +1 -0
- package/src/solver-tools/cvode-method.ts +129 -0
- package/src/solver-tools/index.js +1 -0
- package/src/solver-tools/index.js.map +1 -1
- package/src/solver-tools/index.ts +1 -0
- package/src/solver-tools/lsoda/blas.js +11 -0
- package/src/solver-tools/lsoda/blas.js.map +1 -1
- package/src/solver-tools/lsoda/blas.ts +12 -0
- package/src/solver-tools/lsoda/cfode.js +11 -0
- package/src/solver-tools/lsoda/cfode.js.map +1 -1
- package/src/solver-tools/lsoda/cfode.ts +12 -0
- package/src/solver-tools/lsoda/corfailure.js +11 -0
- package/src/solver-tools/lsoda/corfailure.js.map +1 -1
- package/src/solver-tools/lsoda/corfailure.ts +12 -0
- package/src/solver-tools/lsoda/correction.js +11 -0
- package/src/solver-tools/lsoda/correction.js.map +1 -1
- package/src/solver-tools/lsoda/correction.ts +12 -0
- package/src/solver-tools/lsoda/dense.js +11 -0
- package/src/solver-tools/lsoda/dense.js.map +1 -1
- package/src/solver-tools/lsoda/dense.ts +12 -0
- package/src/solver-tools/lsoda/index.js +11 -0
- package/src/solver-tools/lsoda/index.js.map +1 -1
- package/src/solver-tools/lsoda/index.ts +12 -0
- package/src/solver-tools/lsoda/intdy.js +11 -0
- package/src/solver-tools/lsoda/intdy.js.map +1 -1
- package/src/solver-tools/lsoda/intdy.ts +12 -0
- package/src/solver-tools/lsoda/lsoda.js +11 -0
- package/src/solver-tools/lsoda/lsoda.js.map +1 -1
- package/src/solver-tools/lsoda/lsoda.ts +12 -0
- package/src/solver-tools/lsoda/methodswitch.js +11 -0
- package/src/solver-tools/lsoda/methodswitch.js.map +1 -1
- package/src/solver-tools/lsoda/methodswitch.ts +12 -0
- package/src/solver-tools/lsoda/orderswitch.js +11 -0
- package/src/solver-tools/lsoda/orderswitch.js.map +1 -1
- package/src/solver-tools/lsoda/orderswitch.ts +12 -0
- package/src/solver-tools/lsoda/prja.js +11 -0
- package/src/solver-tools/lsoda/prja.js.map +1 -1
- package/src/solver-tools/lsoda/prja.ts +12 -0
- package/src/solver-tools/lsoda/scaleh.js +11 -0
- package/src/solver-tools/lsoda/scaleh.js.map +1 -1
- package/src/solver-tools/lsoda/scaleh.ts +12 -0
- package/src/solver-tools/lsoda/solsy.js +11 -0
- package/src/solver-tools/lsoda/solsy.js.map +1 -1
- package/src/solver-tools/lsoda/solsy.ts +12 -0
- package/src/solver-tools/lsoda/stoda.js +11 -0
- package/src/solver-tools/lsoda/stoda.js.map +1 -1
- package/src/solver-tools/lsoda/stoda.ts +12 -0
- package/src/solver-tools/lsoda-method.js +23 -9
- package/src/solver-tools/lsoda-method.js.map +1 -1
- package/src/solver-tools/lsoda-method.ts +27 -9
- package/src/solver-tools/solver-defs.js +1 -0
- package/src/solver-tools/solver-defs.js.map +1 -1
- package/src/solver-tools/solver-defs.ts +1 -0
- package/src/tests/cvode-lib-correctness.test.js +404 -0
- package/src/tests/cvode-lib-correctness.test.js.map +1 -0
- package/src/tests/cvode-lib-correctness.test.ts +505 -0
- package/src/tests/cvode-lib-performance.test.js +103 -0
- package/src/tests/cvode-lib-performance.test.js.map +1 -0
- package/src/tests/cvode-lib-performance.test.ts +128 -0
- package/src/tests/performance.test.js +4 -2
- package/src/tests/performance.test.js.map +1 -1
- package/src/tests/performance.test.ts +4 -2
- package/src/tests/test-defs.js +7 -1
- package/src/tests/test-defs.js.map +1 -1
- package/src/tests/test-defs.ts +8 -1
- package/src/worker-tools/solving.js +3 -1
- package/src/worker-tools/solving.js.map +1 -1
- package/src/worker-tools/solving.ts +4 -1
- package/src/examples/bioreactor.js +0 -125
- package/src/examples/bioreactor.js.map +0 -1
- package/src/examples/bioreactor.ts +0 -132
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The OREGO model (see https://archimede.uniba.it/~testset/report/orego.pdf) */
|
|
2
|
+
export const orego = {
|
|
3
|
+
name: 'OREGO',
|
|
4
|
+
arg: {name: 't', start: 0, finish: 360, step: 0.01},
|
|
5
|
+
initial: [1, 2, 3],
|
|
6
|
+
func: (t: number, y: Float64Array, output: Float64Array) => {
|
|
7
|
+
// extract function values
|
|
8
|
+
const y1 = y[0];
|
|
9
|
+
const y2 = y[1];
|
|
10
|
+
const y3 = y[2];
|
|
11
|
+
|
|
12
|
+
// compute output
|
|
13
|
+
output[0] = 77.27 * (y2 - y1 * y2 + y1 - 0.000008375 * y1 * y1 );
|
|
14
|
+
output[1] = 1 / 77.27 * (-y2 - y1 * y2 + y3);
|
|
15
|
+
output[2] = 0.161 * (y1 - y3);
|
|
16
|
+
},
|
|
17
|
+
tolerance: 1e-8,
|
|
18
|
+
solutionColNames: ['y1', 'y2', 'y3'],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const oregoReferencePoint = new Float64Array([
|
|
22
|
+
1.000814870318523,
|
|
23
|
+
1228.178521549917,
|
|
24
|
+
132.0554942846706,
|
|
25
|
+
]);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/** This example shows how to apply pipelines and models with customized outputs.
|
|
3
|
+
This approach can be used for in-webworkers analysis of models.
|
|
4
|
+
|
|
5
|
+
Here, we consider modeling queues: https://en.wikipedia.org/wiki/M/M/c_queue
|
|
6
|
+
*/
|
|
7
|
+
import * as DGL from '../../index';
|
|
8
|
+
/** 1. Model specification: the M|M|2|2 model */
|
|
9
|
+
const model = `#name: M|M|2|2
|
|
10
|
+
#description: Modelling the system with two servers & two waiting places (EXPLAINED)
|
|
11
|
+
#equations:
|
|
12
|
+
dp0/dt = -la * p0 + mu * p1
|
|
13
|
+
dp1/dt = la * p0 - (la + mu) * p1 + 2 * mu * p2
|
|
14
|
+
dp2/dt = la * p1 - (la + 2 * mu) * p2 + 2 * mu * p3
|
|
15
|
+
dp3/dt = la * p2 - (la + 2 * mu) * p3 + 2 * mu * p4
|
|
16
|
+
|
|
17
|
+
#expressions:
|
|
18
|
+
la = 1 / arrival
|
|
19
|
+
mu = 1 / service
|
|
20
|
+
p4 = 1 - p0 - p1 - p2 - p3
|
|
21
|
+
busy = 1 - p0 - p1
|
|
22
|
+
queue = p3 + 2 * p4
|
|
23
|
+
|
|
24
|
+
#argument: t
|
|
25
|
+
_t0 = 0 {min: 0; max: 10; caption: start; category: Time; units: min} [Initial time of simulation]
|
|
26
|
+
_t1 = 60 {min: 20; max: 100; caption: finish; category: Time; units: min} [Final time of simulation]
|
|
27
|
+
_h = 1 {min: 0.01; max: 0.1; caption: step; category: Time; units: min} [Time step of simulation]
|
|
28
|
+
|
|
29
|
+
#inits:
|
|
30
|
+
p0 = 1 {min: 0; max: 1; category: Initial state; caption: empty} [Probability that initially there are NO customers]
|
|
31
|
+
p1 = 0 {min: 0; max: 1; category: Initial state; caption: single} [Probability that initially there is ONE customer]
|
|
32
|
+
p2 = 0 {min: 0; max: 1; category: Initial state; caption: two} [Probability that initially there are TWO customers]
|
|
33
|
+
p3 = 0 {min: 0; max: 1; category: Initial state; caption: three} [Probability that initially there are THREE customers]
|
|
34
|
+
|
|
35
|
+
#output:
|
|
36
|
+
t {caption: Time, min}
|
|
37
|
+
p0 {caption: P(Empty)}
|
|
38
|
+
busy {caption: P(Full load)}
|
|
39
|
+
queue {caption: E(Queue)}
|
|
40
|
+
|
|
41
|
+
#parameters:
|
|
42
|
+
arrival = 10 {min: 1; max: 100; category: Means; caption: arrival; units: min} [Mean arrival time]
|
|
43
|
+
service = 100 {min: 1; max: 100; category: Means; caption: service; units: min} [Mean service time]`;
|
|
44
|
+
/** 2. Generate IVP-objects: for the main thread & for computations in webworkers */
|
|
45
|
+
const ivp = DGL.getIVP(model);
|
|
46
|
+
const ivpWW = DGL.getIvp2WebWorker(ivp);
|
|
47
|
+
/** 3. Perform computations */
|
|
48
|
+
try {
|
|
49
|
+
// 3.1) Extract names of outputs
|
|
50
|
+
const outputNames = DGL.getOutputNames(ivp);
|
|
51
|
+
const outSize = outputNames.length;
|
|
52
|
+
// 3.2) Set model inputs
|
|
53
|
+
const inputs = {
|
|
54
|
+
_t0: 0, // Initial time of simulation
|
|
55
|
+
_t1: 60, // Final time of simulation
|
|
56
|
+
_h: 1, // Time step of simulation
|
|
57
|
+
p0: 1, // Probability that initially there are NO customers
|
|
58
|
+
p1: 0, // Probability that initially there is ONE customer
|
|
59
|
+
p2: 0, // Probability that initially there are TWO customers
|
|
60
|
+
p3: 0, // Probability that initially there are THREE customers
|
|
61
|
+
arrival: 10, // Mean arrival time
|
|
62
|
+
service: 100, // Mean service time
|
|
63
|
+
};
|
|
64
|
+
const inputVector = DGL.getInputVector(inputs, ivp);
|
|
65
|
+
// 3.3) Create a pipeline
|
|
66
|
+
const creator = DGL.getPipelineCreator(ivp);
|
|
67
|
+
const pipeline = creator.getPipeline(inputVector);
|
|
68
|
+
// 3.4) Apply pipeline to perform computations
|
|
69
|
+
const solution = DGL.applyPipeline(pipeline, ivpWW, inputVector);
|
|
70
|
+
// 3.5) Print results
|
|
71
|
+
// 3.5.1) Table header
|
|
72
|
+
let line = '';
|
|
73
|
+
outputNames.forEach((name) => line += name + ' ');
|
|
74
|
+
console.log(line);
|
|
75
|
+
// 3.5.2) Table with solution
|
|
76
|
+
const length = solution[0].length;
|
|
77
|
+
for (let i = 0; i < length; ++i) {
|
|
78
|
+
line = '';
|
|
79
|
+
for (let j = 0; j < outSize; ++j)
|
|
80
|
+
line += solution[j][i].toFixed(8) + ' ';
|
|
81
|
+
console.log(line);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
console.log('Simulation failed: ', err instanceof Error ? err.message : 'Unknown problem!');
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=pipeline-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-use.js","sourceRoot":"","sources":["pipeline-use.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B;;;;EAIE;AAEF,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,iDAAiD;AACjD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAkCyF,CAAC;AAExG,oFAAoF;AACpF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAExC,8BAA8B;AAC9B,IAAI,CAAC;IACH,gCAAgC;IAChC,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC;IAEnC,wBAAwB;IACxB,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,CAAC,EAAE,6BAA6B;QACrC,GAAG,EAAE,EAAE,EA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,OAAO,CAAC;QAE9C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/** This example shows how to apply pipelines and models with customized outputs.
|
|
3
|
+
This approach can be used for in-webworkers analysis of models.
|
|
4
|
+
|
|
5
|
+
Here, we consider modeling queues: https://en.wikipedia.org/wiki/M/M/c_queue
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as DGL from '../../index';
|
|
9
|
+
|
|
10
|
+
/** 1. Model specification: the M|M|2|2 model */
|
|
11
|
+
const model = `#name: M|M|2|2
|
|
12
|
+
#description: Modelling the system with two servers & two waiting places (EXPLAINED)
|
|
13
|
+
#equations:
|
|
14
|
+
dp0/dt = -la * p0 + mu * p1
|
|
15
|
+
dp1/dt = la * p0 - (la + mu) * p1 + 2 * mu * p2
|
|
16
|
+
dp2/dt = la * p1 - (la + 2 * mu) * p2 + 2 * mu * p3
|
|
17
|
+
dp3/dt = la * p2 - (la + 2 * mu) * p3 + 2 * mu * p4
|
|
18
|
+
|
|
19
|
+
#expressions:
|
|
20
|
+
la = 1 / arrival
|
|
21
|
+
mu = 1 / service
|
|
22
|
+
p4 = 1 - p0 - p1 - p2 - p3
|
|
23
|
+
busy = 1 - p0 - p1
|
|
24
|
+
queue = p3 + 2 * p4
|
|
25
|
+
|
|
26
|
+
#argument: t
|
|
27
|
+
_t0 = 0 {min: 0; max: 10; caption: start; category: Time; units: min} [Initial time of simulation]
|
|
28
|
+
_t1 = 60 {min: 20; max: 100; caption: finish; category: Time; units: min} [Final time of simulation]
|
|
29
|
+
_h = 1 {min: 0.01; max: 0.1; caption: step; category: Time; units: min} [Time step of simulation]
|
|
30
|
+
|
|
31
|
+
#inits:
|
|
32
|
+
p0 = 1 {min: 0; max: 1; category: Initial state; caption: empty} [Probability that initially there are NO customers]
|
|
33
|
+
p1 = 0 {min: 0; max: 1; category: Initial state; caption: single} [Probability that initially there is ONE customer]
|
|
34
|
+
p2 = 0 {min: 0; max: 1; category: Initial state; caption: two} [Probability that initially there are TWO customers]
|
|
35
|
+
p3 = 0 {min: 0; max: 1; category: Initial state; caption: three} [Probability that initially there are THREE customers]
|
|
36
|
+
|
|
37
|
+
#output:
|
|
38
|
+
t {caption: Time, min}
|
|
39
|
+
p0 {caption: P(Empty)}
|
|
40
|
+
busy {caption: P(Full load)}
|
|
41
|
+
queue {caption: E(Queue)}
|
|
42
|
+
|
|
43
|
+
#parameters:
|
|
44
|
+
arrival = 10 {min: 1; max: 100; category: Means; caption: arrival; units: min} [Mean arrival time]
|
|
45
|
+
service = 100 {min: 1; max: 100; category: Means; caption: service; units: min} [Mean service time]`;
|
|
46
|
+
|
|
47
|
+
/** 2. Generate IVP-objects: for the main thread & for computations in webworkers */
|
|
48
|
+
const ivp = DGL.getIVP(model);
|
|
49
|
+
const ivpWW = DGL.getIvp2WebWorker(ivp);
|
|
50
|
+
|
|
51
|
+
/** 3. Perform computations */
|
|
52
|
+
try {
|
|
53
|
+
// 3.1) Extract names of outputs
|
|
54
|
+
const outputNames = DGL.getOutputNames(ivp);
|
|
55
|
+
const outSize = outputNames.length;
|
|
56
|
+
|
|
57
|
+
// 3.2) Set model inputs
|
|
58
|
+
const inputs = {
|
|
59
|
+
_t0: 0, // Initial time of simulation
|
|
60
|
+
_t1: 60, // Final time of simulation
|
|
61
|
+
_h: 1, // Time step of simulation
|
|
62
|
+
p0: 1, // Probability that initially there are NO customers
|
|
63
|
+
p1: 0, // Probability that initially there is ONE customer
|
|
64
|
+
p2: 0, // Probability that initially there are TWO customers
|
|
65
|
+
p3: 0, // Probability that initially there are THREE customers
|
|
66
|
+
arrival: 10, // Mean arrival time
|
|
67
|
+
service: 100, // Mean service time
|
|
68
|
+
};
|
|
69
|
+
const inputVector = DGL.getInputVector(inputs, ivp);
|
|
70
|
+
|
|
71
|
+
// 3.3) Create a pipeline
|
|
72
|
+
const creator = DGL.getPipelineCreator(ivp);
|
|
73
|
+
const pipeline = creator.getPipeline(inputVector);
|
|
74
|
+
|
|
75
|
+
// 3.4) Apply pipeline to perform computations
|
|
76
|
+
const solution = DGL.applyPipeline(pipeline, ivpWW, inputVector);
|
|
77
|
+
|
|
78
|
+
// 3.5) Print results
|
|
79
|
+
|
|
80
|
+
// 3.5.1) Table header
|
|
81
|
+
let line = '';
|
|
82
|
+
outputNames.forEach((name) => line += name + ' ');
|
|
83
|
+
console.log(line);
|
|
84
|
+
|
|
85
|
+
// 3.5.2) Table with solution
|
|
86
|
+
const length = solution[0].length;
|
|
87
|
+
for (let i = 0; i < length; ++i) {
|
|
88
|
+
line = '';
|
|
89
|
+
|
|
90
|
+
for (let j = 0; j < outSize; ++j)
|
|
91
|
+
line += solution[j][i].toFixed(8) + ' ';
|
|
92
|
+
|
|
93
|
+
console.log(line);
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.log('Simulation failed: ', err instanceof Error ? err.message : 'Unknown problem!');
|
|
97
|
+
}
|
|
98
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Kintetic constants for the Pollution model */
|
|
2
|
+
var POL;
|
|
3
|
+
(function (POL) {
|
|
4
|
+
POL[POL["K1"] = 0.35] = "K1";
|
|
5
|
+
POL[POL["K2"] = 26.6] = "K2";
|
|
6
|
+
POL[POL["K3"] = 12300] = "K3";
|
|
7
|
+
POL[POL["K4"] = 0.00086] = "K4";
|
|
8
|
+
POL[POL["K5"] = 0.00082] = "K5";
|
|
9
|
+
POL[POL["K6"] = 15000] = "K6";
|
|
10
|
+
POL[POL["K7"] = 0.00013] = "K7";
|
|
11
|
+
POL[POL["K8"] = 24000] = "K8";
|
|
12
|
+
POL[POL["K9"] = 16500] = "K9";
|
|
13
|
+
POL[POL["K10"] = 9000] = "K10";
|
|
14
|
+
POL[POL["K11"] = 0.022] = "K11";
|
|
15
|
+
POL[POL["K12"] = 12000] = "K12";
|
|
16
|
+
POL[POL["K13"] = 1.88] = "K13";
|
|
17
|
+
POL[POL["K14"] = 16300] = "K14";
|
|
18
|
+
POL[POL["K15"] = 4800000] = "K15";
|
|
19
|
+
POL[POL["K16"] = 0.00035] = "K16";
|
|
20
|
+
POL[POL["K17"] = 0.0175] = "K17";
|
|
21
|
+
POL[POL["K18"] = 100000000] = "K18";
|
|
22
|
+
POL[POL["K19"] = 444000000000] = "K19";
|
|
23
|
+
POL[POL["K20"] = 1240] = "K20";
|
|
24
|
+
POL[POL["K21"] = 2.1] = "K21";
|
|
25
|
+
POL[POL["K22"] = 5.78] = "K22";
|
|
26
|
+
POL[POL["K23"] = 0.0474] = "K23";
|
|
27
|
+
POL[POL["K24"] = 1780] = "K24";
|
|
28
|
+
POL[POL["K25"] = 3.12] = "K25";
|
|
29
|
+
})(POL || (POL = {}));
|
|
30
|
+
; // POL
|
|
31
|
+
/** The chemical reaction part of the air pollution model (https://archimede.uniba.it/~testset/report/pollu.pdf) */
|
|
32
|
+
export const pollution = {
|
|
33
|
+
name: 'Pollution',
|
|
34
|
+
arg: { name: 't', start: 0, finish: 60, step: 0.002 },
|
|
35
|
+
initial: [0, 0.2, 0, 0.04, 0, 0, 0.1, 0.3, 0.01, 0, 0, 0, 0, 0, 0, 0, 0.007, 0, 0, 0],
|
|
36
|
+
func: (t, y, output) => {
|
|
37
|
+
// extract function values
|
|
38
|
+
const y1 = y[0];
|
|
39
|
+
const y2 = y[1];
|
|
40
|
+
const y3 = y[2];
|
|
41
|
+
const y4 = y[3];
|
|
42
|
+
const y5 = y[4];
|
|
43
|
+
const y6 = y[5];
|
|
44
|
+
const y7 = y[6];
|
|
45
|
+
const y8 = y[7];
|
|
46
|
+
const y9 = y[8];
|
|
47
|
+
const y10 = y[9];
|
|
48
|
+
const y11 = y[10];
|
|
49
|
+
const y12 = y[11];
|
|
50
|
+
const y13 = y[12];
|
|
51
|
+
const y14 = y[13];
|
|
52
|
+
const y15 = y[14];
|
|
53
|
+
const y16 = y[15];
|
|
54
|
+
const y17 = y[16];
|
|
55
|
+
const y18 = y[17];
|
|
56
|
+
const y19 = y[18];
|
|
57
|
+
const y20 = y[19];
|
|
58
|
+
// evaluate expressions
|
|
59
|
+
const r1 = POL.K1 * y1;
|
|
60
|
+
const r2 = POL.K2 * y2 * y4;
|
|
61
|
+
const r3 = POL.K3 * y5 * y2;
|
|
62
|
+
const r4 = POL.K4 * y7;
|
|
63
|
+
const r5 = POL.K5 * y7;
|
|
64
|
+
const r6 = POL.K6 * y7 * y6;
|
|
65
|
+
const r7 = POL.K7 * y9;
|
|
66
|
+
const r8 = POL.K8 * y9 * y6;
|
|
67
|
+
const r9 = POL.K9 * y11 * y2;
|
|
68
|
+
const r10 = POL.K10 * y11 * y1;
|
|
69
|
+
const r11 = POL.K11 * y13;
|
|
70
|
+
const r12 = POL.K12 * y10 * y2;
|
|
71
|
+
const r13 = POL.K13 * y14;
|
|
72
|
+
const r14 = POL.K14 * y1 * y6;
|
|
73
|
+
const r15 = POL.K15 * y3;
|
|
74
|
+
const r16 = POL.K16 * y4;
|
|
75
|
+
const r17 = POL.K17 * y4;
|
|
76
|
+
const r18 = POL.K18 * y16;
|
|
77
|
+
const r19 = POL.K19 * y16;
|
|
78
|
+
const r20 = POL.K20 * y17 * y6;
|
|
79
|
+
const r21 = POL.K21 * y19;
|
|
80
|
+
const r22 = POL.K22 * y19;
|
|
81
|
+
const r23 = POL.K23 * y1 * y4;
|
|
82
|
+
const r24 = POL.K24 * y19 * y1;
|
|
83
|
+
const r25 = POL.K25 * y20;
|
|
84
|
+
// compute output
|
|
85
|
+
output[0] = -(r1 + r10 + r14 + r23 + r24) + (r2 + r3 + r9 + r11 + r12 + r22 + r25);
|
|
86
|
+
output[1] = -r2 - r3 - r9 - r12 + r1 + r21;
|
|
87
|
+
output[2] = -r15 + r1 + r17 + r19 + r22;
|
|
88
|
+
output[3] = -r2 - r16 - r17 - r23 + r15;
|
|
89
|
+
output[4] = -r3 + 2 * r4 + r6 + r7 + r13 + r20;
|
|
90
|
+
output[5] = -r6 - r8 - r14 - r20 + r3 + 2 * r18;
|
|
91
|
+
output[6] = -r4 - r5 - r6 + r13;
|
|
92
|
+
output[7] = r4 + r5 + r6 + r7;
|
|
93
|
+
output[8] = -r7 - r8;
|
|
94
|
+
output[9] = -r12 + r7 + r9;
|
|
95
|
+
output[10] = -r9 - r10 + r8 + r11;
|
|
96
|
+
output[11] = r9;
|
|
97
|
+
output[12] = -r11 + r10;
|
|
98
|
+
output[13] = -r13 + r12;
|
|
99
|
+
output[14] = r14;
|
|
100
|
+
output[15] = -r18 - r19 + r16;
|
|
101
|
+
output[16] = -r20;
|
|
102
|
+
output[17] = r20;
|
|
103
|
+
output[18] = -r21 - r22 - r24 + r23 + r25;
|
|
104
|
+
output[19] = -r25 + r24;
|
|
105
|
+
},
|
|
106
|
+
tolerance: 1e-6,
|
|
107
|
+
solutionColNames: ['y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9', 'y10', 'y11',
|
|
108
|
+
'y12', 'y13', 'y14', 'y15', 'y16', 'y17', 'y18', 'y19', 'y20'],
|
|
109
|
+
}; // pollution
|
|
110
|
+
export const pollutionReferencePoint = new Float64Array([
|
|
111
|
+
0.05646255480022769,
|
|
112
|
+
0.1342484130422339,
|
|
113
|
+
0.4139734331099427E-8,
|
|
114
|
+
0.5523140207484359E-2,
|
|
115
|
+
0.2018977262302196E-6,
|
|
116
|
+
0.1464541863493966E-6,
|
|
117
|
+
0.7784249118997964E-1,
|
|
118
|
+
0.3245075353396018,
|
|
119
|
+
0.7494013383880406E-2,
|
|
120
|
+
0.1622293157301561E-7,
|
|
121
|
+
0.1135863833257075E-7,
|
|
122
|
+
0.2230505975721359E-2,
|
|
123
|
+
0.2087162882798630E-3,
|
|
124
|
+
0.1396921016840158E-4,
|
|
125
|
+
0.8964884856898295E-2,
|
|
126
|
+
0.4352846369330103E-17,
|
|
127
|
+
0.6899219696263405E-2,
|
|
128
|
+
0.1007803037365946E-3,
|
|
129
|
+
0.1772146513969984E-5,
|
|
130
|
+
0.5682943292316392E-4,
|
|
131
|
+
]);
|
|
132
|
+
//# sourceMappingURL=pollution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollution.js","sourceRoot":"","sources":["pollution.ts"],"names":[],"mappings":"AAAE,iDAAiD;AACjD,IAAK,GA0BJ;AA1BD,WAAK,GAAG;IACN,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,6BAAW,CAAA;IACX,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,6BAAU,CAAA;IACV,+BAAW,CAAA;IACX,6BAAU,CAAA;IACV,6BAAW,CAAA;IACX,8BAAS,CAAA;IACT,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,8BAAU,CAAA;IACV,+BAAY,CAAA;IACZ,iCAAW,CAAA;IACX,iCAAY,CAAA;IACZ,gCAAY,CAAA;IACZ,mCAAS,CAAA;IACT,sCAAa,CAAA;IACb,8BAAU,CAAA;IACV,6BAAS,CAAA;IACT,8BAAU,CAAA;IACV,gCAAY,CAAA;IACZ,8BAAU,CAAA;IACV,8BAAU,CAAA;AACZ,CAAC,EA1BI,GAAG,KAAH,GAAG,QA0BP;AAAA,CAAC,CAAC,MAAM;AAEX,mHAAmH;AACnH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAC;IACnD,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,C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,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK;QACnF,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;CACjE,CAAC,CAAC,YAAY;AAEf,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,YAAY,CAAC;IACtD,mBAAmB;IACnB,kBAAkB;IAClB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,kBAAkB;IAClB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Kintetic constants for the Pollution model */
|
|
2
|
+
enum POL {
|
|
3
|
+
K1 = 0.35,
|
|
4
|
+
K2 = 26.6,
|
|
5
|
+
K3 = 1.23e4,
|
|
6
|
+
K4 = 8.6e-4,
|
|
7
|
+
K5 = 8.2e-4,
|
|
8
|
+
K6 = 1.5e4,
|
|
9
|
+
K7 = 1.3e-4,
|
|
10
|
+
K8 = 2.4e4,
|
|
11
|
+
K9 = 1.65e4,
|
|
12
|
+
K10 = 9e3,
|
|
13
|
+
K11 = 0.022,
|
|
14
|
+
K12 = 1.2e4,
|
|
15
|
+
K13 = 1.88,
|
|
16
|
+
K14 = 1.63e4,
|
|
17
|
+
K15 = 4.8e6,
|
|
18
|
+
K16 = 3.5e-4,
|
|
19
|
+
K17 = 0.0175,
|
|
20
|
+
K18 = 1e8,
|
|
21
|
+
K19 = 4.44e11,
|
|
22
|
+
K20 = 1240,
|
|
23
|
+
K21 = 2.1,
|
|
24
|
+
K22 = 5.78,
|
|
25
|
+
K23 = 0.0474,
|
|
26
|
+
K24 = 1780,
|
|
27
|
+
K25 = 3.12,
|
|
28
|
+
}; // POL
|
|
29
|
+
|
|
30
|
+
/** The chemical reaction part of the air pollution model (https://archimede.uniba.it/~testset/report/pollu.pdf) */
|
|
31
|
+
export const pollution = {
|
|
32
|
+
name: 'Pollution',
|
|
33
|
+
arg: {name: 't', start: 0, finish: 60, step: 0.002},
|
|
34
|
+
initial: [0, 0.2, 0, 0.04, 0, 0, 0.1, 0.3, 0.01, 0, 0, 0, 0, 0, 0, 0, 0.007, 0, 0, 0],
|
|
35
|
+
func: (t: number, y: Float64Array, output: Float64Array) => {
|
|
36
|
+
// extract function values
|
|
37
|
+
const y1 = y[0];
|
|
38
|
+
const y2 = y[1];
|
|
39
|
+
const y3 = y[2];
|
|
40
|
+
const y4 = y[3];
|
|
41
|
+
const y5 = y[4];
|
|
42
|
+
const y6 = y[5];
|
|
43
|
+
const y7 = y[6];
|
|
44
|
+
const y8 = y[7];
|
|
45
|
+
const y9 = y[8];
|
|
46
|
+
const y10 = y[9];
|
|
47
|
+
const y11 = y[10];
|
|
48
|
+
const y12 = y[11];
|
|
49
|
+
const y13 = y[12];
|
|
50
|
+
const y14 = y[13];
|
|
51
|
+
const y15 = y[14];
|
|
52
|
+
const y16 = y[15];
|
|
53
|
+
const y17 = y[16];
|
|
54
|
+
const y18 = y[17];
|
|
55
|
+
const y19 = y[18];
|
|
56
|
+
const y20 = y[19];
|
|
57
|
+
|
|
58
|
+
// evaluate expressions
|
|
59
|
+
const r1 = POL.K1 * y1;
|
|
60
|
+
const r2 = POL.K2 * y2 * y4;
|
|
61
|
+
const r3 = POL.K3 * y5 * y2;
|
|
62
|
+
const r4 = POL.K4 * y7;
|
|
63
|
+
const r5 = POL.K5 * y7;
|
|
64
|
+
const r6 = POL.K6 * y7 * y6;
|
|
65
|
+
const r7 = POL.K7 * y9;
|
|
66
|
+
const r8 = POL.K8 * y9 * y6;
|
|
67
|
+
const r9 = POL.K9 * y11 * y2;
|
|
68
|
+
const r10 = POL.K10 * y11 * y1;
|
|
69
|
+
const r11 = POL.K11 * y13;
|
|
70
|
+
const r12 = POL.K12 * y10 * y2;
|
|
71
|
+
const r13 = POL.K13 * y14;
|
|
72
|
+
const r14 = POL.K14 * y1 * y6;
|
|
73
|
+
const r15 = POL.K15 * y3;
|
|
74
|
+
const r16 = POL.K16 * y4;
|
|
75
|
+
const r17 = POL.K17 * y4;
|
|
76
|
+
const r18 = POL.K18 * y16;
|
|
77
|
+
const r19 = POL.K19 * y16;
|
|
78
|
+
const r20 = POL.K20 * y17 * y6;
|
|
79
|
+
const r21 = POL.K21 * y19;
|
|
80
|
+
const r22 = POL.K22 * y19;
|
|
81
|
+
const r23 = POL.K23 * y1 * y4;
|
|
82
|
+
const r24 = POL.K24 * y19 * y1;
|
|
83
|
+
const r25 = POL.K25 * y20;
|
|
84
|
+
|
|
85
|
+
// compute output
|
|
86
|
+
output[0] = -(r1 + r10 + r14 + r23 + r24) + (r2 + r3 + r9 + r11 + r12 + r22 + r25);
|
|
87
|
+
output[1] = -r2 - r3 - r9 - r12 + r1 + r21;
|
|
88
|
+
output[2] = -r15 + r1 + r17 + r19 + r22;
|
|
89
|
+
output[3] = -r2 - r16 - r17 - r23 + r15;
|
|
90
|
+
output[4] = -r3 +2 * r4 + r6 +r7 +r13 + r20;
|
|
91
|
+
output[5] = -r6 - r8 - r14 - r20 + r3 + 2 * r18;
|
|
92
|
+
output[6] = -r4 - r5 - r6 + r13;
|
|
93
|
+
output[7] = r4 + r5 + r6 + r7;
|
|
94
|
+
output[8] = -r7 - r8;
|
|
95
|
+
output[9] = -r12 +r7 + r9;
|
|
96
|
+
output[10] = -r9 - r10 + r8 + r11;
|
|
97
|
+
output[11] = r9;
|
|
98
|
+
output[12] = -r11 + r10;
|
|
99
|
+
output[13] = -r13 + r12;
|
|
100
|
+
output[14] = r14;
|
|
101
|
+
output[15] = -r18 - r19 + r16;
|
|
102
|
+
output[16] = -r20;
|
|
103
|
+
output[17] = r20;
|
|
104
|
+
output[18] = -r21 - r22 - r24 + r23 + r25;
|
|
105
|
+
output[19] = -r25 + r24;
|
|
106
|
+
},
|
|
107
|
+
tolerance: 1e-6,
|
|
108
|
+
solutionColNames: ['y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9', 'y10', 'y11',
|
|
109
|
+
'y12', 'y13', 'y14', 'y15', 'y16', 'y17', 'y18', 'y19', 'y20'],
|
|
110
|
+
}; // pollution
|
|
111
|
+
|
|
112
|
+
export const pollutionReferencePoint = new Float64Array([
|
|
113
|
+
0.05646255480022769,
|
|
114
|
+
0.1342484130422339,
|
|
115
|
+
0.4139734331099427E-8,
|
|
116
|
+
0.5523140207484359E-2,
|
|
117
|
+
0.2018977262302196E-6,
|
|
118
|
+
0.1464541863493966E-6,
|
|
119
|
+
0.7784249118997964E-1,
|
|
120
|
+
0.3245075353396018,
|
|
121
|
+
0.7494013383880406E-2,
|
|
122
|
+
0.1622293157301561E-7,
|
|
123
|
+
0.1135863833257075E-7,
|
|
124
|
+
0.2230505975721359E-2,
|
|
125
|
+
0.2087162882798630E-3,
|
|
126
|
+
0.1396921016840158E-4,
|
|
127
|
+
0.8964884856898295E-2,
|
|
128
|
+
0.4352846369330103E-17,
|
|
129
|
+
0.6899219696263405E-2,
|
|
130
|
+
0.1007803037365946E-3,
|
|
131
|
+
0.1772146513969984E-5,
|
|
132
|
+
0.5682943292316392E-4,
|
|
133
|
+
]);
|