diff-grok 1.0.8
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/.eslintrc.json +45 -0
- package/.github/scripts/bump-js-api-version.sh +106 -0
- package/.github/scripts/check-output.sh +20 -0
- package/.github/scripts/iac-cfn-deploy.sh +90 -0
- package/.github/scripts/slack_api_request.sh +65 -0
- package/.github/scripts/test_package.sh +270 -0
- package/.github/workflows/libraries.yaml +305 -0
- package/LICENSE +21 -0
- package/README.MD +396 -0
- package/eslintrc.json +45 -0
- package/images/acid-prod.gif +0 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/index.ts +15 -0
- package/package.json +45 -0
- package/src/examples/basic-use.js +40 -0
- package/src/examples/basic-use.js.map +1 -0
- package/src/examples/basic-use.ts +44 -0
- package/src/examples/check-methods.js +45 -0
- package/src/examples/check-methods.js.map +1 -0
- package/src/examples/check-methods.ts +62 -0
- package/src/examples/corr-probs.js +130 -0
- package/src/examples/corr-probs.js.map +1 -0
- package/src/examples/corr-probs.ts +151 -0
- package/src/examples/cyclic-model.js +100 -0
- package/src/examples/cyclic-model.js.map +1 -0
- package/src/examples/cyclic-model.ts +110 -0
- package/src/examples/e5.js +30 -0
- package/src/examples/e5.js.map +1 -0
- package/src/examples/e5.ts +29 -0
- package/src/examples/hires.js +29 -0
- package/src/examples/hires.js.map +1 -0
- package/src/examples/hires.ts +29 -0
- package/src/examples/index.js +17 -0
- package/src/examples/index.js.map +1 -0
- package/src/examples/index.ts +18 -0
- package/src/examples/model-updates.js +112 -0
- package/src/examples/model-updates.js.map +1 -0
- package/src/examples/model-updates.ts +122 -0
- package/src/examples/orego.js +19 -0
- package/src/examples/orego.js.map +1 -0
- package/src/examples/orego.ts +19 -0
- package/src/examples/pipeline-use.js +87 -0
- package/src/examples/pipeline-use.js.map +1 -0
- package/src/examples/pipeline-use.ts +98 -0
- package/src/examples/pollution.js +110 -0
- package/src/examples/pollution.js.map +1 -0
- package/src/examples/pollution.ts +110 -0
- package/src/examples/robertson.js +14 -0
- package/src/examples/robertson.js.map +1 -0
- package/src/examples/robertson.ts +13 -0
- package/src/examples/scripting.js +31 -0
- package/src/examples/scripting.js.map +1 -0
- package/src/examples/scripting.ts +36 -0
- package/src/examples/vdpol.js +13 -0
- package/src/examples/vdpol.js.map +1 -0
- package/src/examples/vdpol.ts +12 -0
- package/src/pipeline/basic-pipeline-creator.js +21 -0
- package/src/pipeline/basic-pipeline-creator.js.map +1 -0
- package/src/pipeline/basic-pipeline-creator.ts +24 -0
- package/src/pipeline/constants.js +21 -0
- package/src/pipeline/constants.js.map +1 -0
- package/src/pipeline/constants.ts +21 -0
- package/src/pipeline/index.js +8 -0
- package/src/pipeline/index.js.map +1 -0
- package/src/pipeline/index.ts +7 -0
- package/src/pipeline/input.js +45 -0
- package/src/pipeline/input.js.map +1 -0
- package/src/pipeline/input.ts +55 -0
- package/src/pipeline/loops-pipeline-creator.js +107 -0
- package/src/pipeline/loops-pipeline-creator.js.map +1 -0
- package/src/pipeline/loops-pipeline-creator.ts +138 -0
- package/src/pipeline/output.js +146 -0
- package/src/pipeline/output.js.map +1 -0
- package/src/pipeline/output.ts +196 -0
- package/src/pipeline/pipeline-creator.js +10 -0
- package/src/pipeline/pipeline-creator.js.map +1 -0
- package/src/pipeline/pipeline-creator.ts +16 -0
- package/src/pipeline/pipeline.js +71 -0
- package/src/pipeline/pipeline.js.map +1 -0
- package/src/pipeline/pipeline.ts +104 -0
- package/src/pipeline/updates-pipeline-creator.js +98 -0
- package/src/pipeline/updates-pipeline-creator.js.map +1 -0
- package/src/pipeline/updates-pipeline-creator.ts +125 -0
- package/src/scripting-tools/constants.js +53 -0
- package/src/scripting-tools/constants.js.map +1 -0
- package/src/scripting-tools/constants.ts +51 -0
- package/src/scripting-tools/index.js +4 -0
- package/src/scripting-tools/index.js.map +1 -0
- package/src/scripting-tools/index.ts +7 -0
- package/src/scripting-tools/model-error.js +17 -0
- package/src/scripting-tools/model-error.js.map +1 -0
- package/src/scripting-tools/model-error.ts +19 -0
- package/src/scripting-tools/scripting-tools.js +1032 -0
- package/src/scripting-tools/scripting-tools.js.map +1 -0
- package/src/scripting-tools/scripting-tools.ts +1375 -0
- package/src/solver-tools/callbacks/callback-base.js +10 -0
- package/src/solver-tools/callbacks/callback-base.js.map +1 -0
- package/src/solver-tools/callbacks/callback-base.ts +8 -0
- package/src/solver-tools/callbacks/callback-tools.js +14 -0
- package/src/solver-tools/callbacks/callback-tools.js.map +1 -0
- package/src/solver-tools/callbacks/callback-tools.ts +20 -0
- package/src/solver-tools/callbacks/iter-checker-callback.js +16 -0
- package/src/solver-tools/callbacks/iter-checker-callback.js.map +1 -0
- package/src/solver-tools/callbacks/iter-checker-callback.ts +21 -0
- package/src/solver-tools/callbacks/time-checker-callback.js +17 -0
- package/src/solver-tools/callbacks/time-checker-callback.js.map +1 -0
- package/src/solver-tools/callbacks/time-checker-callback.ts +19 -0
- package/src/solver-tools/index.js +6 -0
- package/src/solver-tools/index.js.map +1 -0
- package/src/solver-tools/index.ts +6 -0
- package/src/solver-tools/lin-alg-tools.js +56 -0
- package/src/solver-tools/lin-alg-tools.js.map +1 -0
- package/src/solver-tools/lin-alg-tools.ts +75 -0
- package/src/solver-tools/mrt-method.js +210 -0
- package/src/solver-tools/mrt-method.js.map +1 -0
- package/src/solver-tools/mrt-method.ts +269 -0
- package/src/solver-tools/ros34prw-method.js +257 -0
- package/src/solver-tools/ros34prw-method.js.map +1 -0
- package/src/solver-tools/ros34prw-method.ts +335 -0
- package/src/solver-tools/ros3prw-method.js +233 -0
- package/src/solver-tools/ros3prw-method.js.map +1 -0
- package/src/solver-tools/ros3prw-method.ts +304 -0
- package/src/solver-tools/solver-defs.js +58 -0
- package/src/solver-tools/solver-defs.js.map +1 -0
- package/src/solver-tools/solver-defs.ts +100 -0
- package/src/worker-tools/index.js +3 -0
- package/src/worker-tools/index.js.map +1 -0
- package/src/worker-tools/index.ts +2 -0
- package/src/worker-tools/scripting.js +68 -0
- package/src/worker-tools/scripting.js.map +1 -0
- package/src/worker-tools/scripting.ts +95 -0
- package/src/worker-tools/solving.js +48 -0
- package/src/worker-tools/solving.js.map +1 -0
- package/src/worker-tools/solving.ts +60 -0
- package/tsconfig.json +71 -0
|
@@ -0,0 +1,110 @@
|
|
|
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
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Robertson chemical reaction, updated version (see https://archimede.uniba.it/~testset/problems/rober.php) */
|
|
2
|
+
export const robertson = {
|
|
3
|
+
name: 'Robertson',
|
|
4
|
+
arg: { name: 't', start: 0, finish: 10e11, step: 2.5e7 },
|
|
5
|
+
initial: [1, 0, 0],
|
|
6
|
+
func: (t, y, output) => {
|
|
7
|
+
output[0] = -0.04 * y[0] + 1e4 * y[1] * y[2];
|
|
8
|
+
output[1] = 0.04 * y[0] - 1e4 * y[1] * y[2] - 3e7 * Math.pow(y[1], 2);
|
|
9
|
+
output[2] = 3e7 * Math.pow(y[1], 2);
|
|
10
|
+
},
|
|
11
|
+
tolerance: 1e-7,
|
|
12
|
+
solutionColNames: ['A', 'B', 'C'],
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=robertson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robertson.js","sourceRoot":"","sources":["robertson.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC;IACtD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClB,IAAI,EAAE,CAAC,CAAS,EAAE,CAAe,EAAE,MAAoB,EAAE,EAAE;QACzD,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAA,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA,CAAC;QAC5D,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAA,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA,CAAC;IAC5B,CAAC;IACD,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Robertson chemical reaction, updated version (see https://archimede.uniba.it/~testset/problems/rober.php) */
|
|
2
|
+
export const robertson = {
|
|
3
|
+
name: 'Robertson',
|
|
4
|
+
arg: {name: 't', start: 0, finish: 10e11, step: 2.5e7},
|
|
5
|
+
initial: [1, 0, 0],
|
|
6
|
+
func: (t: number, y: Float64Array, output: Float64Array) => {
|
|
7
|
+
output[0] = -0.04 * y[0] + 1e4 * y[1] * y[2];
|
|
8
|
+
output[1] = 0.04 * y[0] - 1e4 * y[1] * y[2] - 3e7 * y[1]**2;
|
|
9
|
+
output[2] = 3e7 * y[1]**2;
|
|
10
|
+
},
|
|
11
|
+
tolerance: 1e-7,
|
|
12
|
+
solutionColNames: ['A', 'B', 'C'],
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getIVP, getJScode } from '../../index';
|
|
2
|
+
/** Example. Solve the following initial value problem
|
|
3
|
+
|
|
4
|
+
dx / dt = x + y - cos(t)
|
|
5
|
+
dy / dt = x - y + sin(t)
|
|
6
|
+
x(0) = 1
|
|
7
|
+
y(0) = 0
|
|
8
|
+
|
|
9
|
+
on [0, 1] with the step 0.01.
|
|
10
|
+
*/
|
|
11
|
+
/** Diff Studio mode specifying the given problem */
|
|
12
|
+
const model = `#name: Example
|
|
13
|
+
#equations:
|
|
14
|
+
dx/dt = x + y - cos(t)
|
|
15
|
+
dy/dt = x - y + sin(t)
|
|
16
|
+
|
|
17
|
+
#inits:
|
|
18
|
+
x = 1
|
|
19
|
+
y = 0
|
|
20
|
+
|
|
21
|
+
#argument: t
|
|
22
|
+
start = 0
|
|
23
|
+
finish = 1
|
|
24
|
+
step = 0.01`;
|
|
25
|
+
// Get parsed formulas
|
|
26
|
+
const ivp = getIVP(model);
|
|
27
|
+
console.log(ivp);
|
|
28
|
+
// Get lines of JS-code specifying ODEs object
|
|
29
|
+
const lines = getJScode(ivp);
|
|
30
|
+
console.log(lines);
|
|
31
|
+
//# sourceMappingURL=scripting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripting.js","sourceRoot":"","sources":["scripting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAE9C;;;;;;;;GAQG;AAEH,oDAAoD;AACpD,MAAM,KAAK,GAAG;;;;;;;;;;;;cAYA,CAAC;AAEf,sBAAsB;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAE1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB,8CAA8C;AAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;AAE7B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {getIVP, getJScode} from '../../index';
|
|
2
|
+
|
|
3
|
+
/** Example. Solve the following initial value problem
|
|
4
|
+
|
|
5
|
+
dx / dt = x + y - cos(t)
|
|
6
|
+
dy / dt = x - y + sin(t)
|
|
7
|
+
x(0) = 1
|
|
8
|
+
y(0) = 0
|
|
9
|
+
|
|
10
|
+
on [0, 1] with the step 0.01.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Diff Studio mode specifying the given problem */
|
|
14
|
+
const model = `#name: Example
|
|
15
|
+
#equations:
|
|
16
|
+
dx/dt = x + y - cos(t)
|
|
17
|
+
dy/dt = x - y + sin(t)
|
|
18
|
+
|
|
19
|
+
#inits:
|
|
20
|
+
x = 1
|
|
21
|
+
y = 0
|
|
22
|
+
|
|
23
|
+
#argument: t
|
|
24
|
+
start = 0
|
|
25
|
+
finish = 1
|
|
26
|
+
step = 0.01`;
|
|
27
|
+
|
|
28
|
+
// Get parsed formulas
|
|
29
|
+
const ivp = getIVP(model);
|
|
30
|
+
|
|
31
|
+
console.log(ivp);
|
|
32
|
+
|
|
33
|
+
// Get lines of JS-code specifying ODEs object
|
|
34
|
+
const lines = getJScode(ivp);
|
|
35
|
+
|
|
36
|
+
console.log(lines);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Van der Pol oscillator (see https://archimede.uniba.it/~testset/problems/vdpol.php) */
|
|
2
|
+
export const vdpol = {
|
|
3
|
+
name: 'van der Pol',
|
|
4
|
+
arg: { name: 't', start: 0, finish: 2000, step: 0.1 },
|
|
5
|
+
initial: [-1, 1],
|
|
6
|
+
func: (t, y, output) => {
|
|
7
|
+
output[0] = y[1];
|
|
8
|
+
output[1] = -y[0] + 1000 * (1 - y[0] * y[0]) * y[1];
|
|
9
|
+
},
|
|
10
|
+
tolerance: 1e-12,
|
|
11
|
+
solutionColNames: ['x1', 'x2'],
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=vdpol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vdpol.js","sourceRoot":"","sources":["vdpol.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAC;IACnD,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChB,IAAI,EAAE,CAAC,CAAS,EAAE,CAAe,EAAE,MAAoB,EAAE,EAAE;QACzD,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,SAAS,EAAE,KAAK;IAChB,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Van der Pol oscillator (see https://archimede.uniba.it/~testset/problems/vdpol.php) */
|
|
2
|
+
export const vdpol = {
|
|
3
|
+
name: 'van der Pol',
|
|
4
|
+
arg: {name: 't', start: 0, finish: 2000, step: 0.1},
|
|
5
|
+
initial: [-1, 1],
|
|
6
|
+
func: (t: number, y: Float64Array, output: Float64Array) => {
|
|
7
|
+
output[0] = y[1];
|
|
8
|
+
output[1] = -y[0] + 1000 * (1 - y[0] * y[0]) * y[1];
|
|
9
|
+
},
|
|
10
|
+
tolerance: 1e-12,
|
|
11
|
+
solutionColNames: ['x1', 'x2'],
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getOutputCode } from './output';
|
|
2
|
+
import { PipelineCreator } from './pipeline-creator';
|
|
3
|
+
/** Pipeline creator for model without loops & updates */
|
|
4
|
+
export class BasicModelPipelineCreator extends PipelineCreator {
|
|
5
|
+
constructor(ivp) {
|
|
6
|
+
super(ivp);
|
|
7
|
+
}
|
|
8
|
+
getPipeline(inputs) {
|
|
9
|
+
return {
|
|
10
|
+
wrappers: [
|
|
11
|
+
{
|
|
12
|
+
preproc: null,
|
|
13
|
+
out: null,
|
|
14
|
+
postproc: null,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
out: getOutputCode(this.ivp),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
} // BasicModelPipelineCreator
|
|
21
|
+
//# sourceMappingURL=basic-pipeline-creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-pipeline-creator.js","sourceRoot":"","sources":["basic-pipeline-creator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD,yDAAyD;AACzD,MAAM,OAAO,yBAA0B,SAAQ,eAAe;IAC5D,YAAY,GAAQ;QAClB,KAAK,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IAEM,WAAW,CAAC,MAAoB;QACrC,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,IAAI;oBACb,GAAG,EAAE,IAAI;oBACT,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF,CAAC,4BAA4B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {IVP} from '../scripting-tools';
|
|
2
|
+
import {getOutputCode} from './output';
|
|
3
|
+
import {Pipeline} from './pipeline';
|
|
4
|
+
import {PipelineCreator} from './pipeline-creator';
|
|
5
|
+
|
|
6
|
+
/** Pipeline creator for model without loops & updates */
|
|
7
|
+
export class BasicModelPipelineCreator extends PipelineCreator {
|
|
8
|
+
constructor(ivp: IVP) {
|
|
9
|
+
super(ivp);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public getPipeline(inputs: Float64Array): Pipeline {
|
|
13
|
+
return {
|
|
14
|
+
wrappers: [
|
|
15
|
+
{
|
|
16
|
+
preproc: null,
|
|
17
|
+
out: null,
|
|
18
|
+
postproc: null,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
out: getOutputCode(this.ivp),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
} // BasicModelPipelineCreator
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const ARG_INP_COUNT = 3;
|
|
2
|
+
export const ARG_COL_IDX = 0;
|
|
3
|
+
export const CORRECTION_FACTOR = 0.5;
|
|
4
|
+
export const DEFAULT_CORRECTION = 0.0000001;
|
|
5
|
+
export const LOOP_PARAMS_CONT = 1;
|
|
6
|
+
export const LOOP_MIN_COUNT = 1;
|
|
7
|
+
/** Default argument names*/
|
|
8
|
+
export var ARG;
|
|
9
|
+
(function (ARG) {
|
|
10
|
+
ARG["START"] = "_t0";
|
|
11
|
+
ARG["FINISH"] = "_t1";
|
|
12
|
+
ARG["STEP"] = "_h";
|
|
13
|
+
})(ARG || (ARG = {}));
|
|
14
|
+
;
|
|
15
|
+
export const LOOP_COUNT_NAME = '_count';
|
|
16
|
+
export const argName2IdxMap = new Map([
|
|
17
|
+
[ARG.START, 0],
|
|
18
|
+
[ARG.FINISH, 1],
|
|
19
|
+
[ARG.STEP, 2],
|
|
20
|
+
]);
|
|
21
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,4BAA4B;AAC5B,MAAM,CAAN,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,oBAAa,CAAA;IACb,qBAAc,CAAA;IACd,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,KAAH,GAAG,QAId;AAAA,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAiB;IACpD,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IACd,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACf,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const ARG_INP_COUNT = 3;
|
|
2
|
+
export const ARG_COL_IDX = 0;
|
|
3
|
+
export const CORRECTION_FACTOR = 0.5;
|
|
4
|
+
export const DEFAULT_CORRECTION = 0.0000001;
|
|
5
|
+
export const LOOP_PARAMS_CONT = 1;
|
|
6
|
+
export const LOOP_MIN_COUNT = 1;
|
|
7
|
+
|
|
8
|
+
/** Default argument names*/
|
|
9
|
+
export enum ARG {
|
|
10
|
+
START = '_t0',
|
|
11
|
+
FINISH = '_t1',
|
|
12
|
+
STEP = '_h',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const LOOP_COUNT_NAME = '_count';
|
|
16
|
+
|
|
17
|
+
export const argName2IdxMap = new Map<string, number>([
|
|
18
|
+
[ARG.START, 0],
|
|
19
|
+
[ARG.FINISH, 1],
|
|
20
|
+
[ARG.STEP, 2],
|
|
21
|
+
]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { applyPipeline, getPipelineCreator } from './pipeline';
|
|
2
|
+
export { getOutputCode, getOutputNames } from './output';
|
|
3
|
+
export { PipelineCreator } from './pipeline-creator';
|
|
4
|
+
export { BasicModelPipelineCreator } from './basic-pipeline-creator';
|
|
5
|
+
export { CyclicModelPipelineCreator } from './loops-pipeline-creator';
|
|
6
|
+
export { UpdatesModelPipelineCreator } from './updates-pipeline-creator';
|
|
7
|
+
export { getInputVector } from './input';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAChF,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,yBAAyB,EAAC,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAC,0BAA0B,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAC,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export {Pipeline, Wrapper, applyPipeline, getPipelineCreator} from './pipeline';
|
|
2
|
+
export {getOutputCode, getOutputNames} from './output';
|
|
3
|
+
export {PipelineCreator} from './pipeline-creator';
|
|
4
|
+
export {BasicModelPipelineCreator} from './basic-pipeline-creator';
|
|
5
|
+
export {CyclicModelPipelineCreator} from './loops-pipeline-creator';
|
|
6
|
+
export {UpdatesModelPipelineCreator} from './updates-pipeline-creator';
|
|
7
|
+
export {getInputVector} from './input';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ARG_INP_COUNT, argName2IdxMap, LOOP_PARAMS_CONT, LOOP_COUNT_NAME } from './constants';
|
|
2
|
+
/** Return inputs in a form of a vector */
|
|
3
|
+
export function getInputVector(inputs, ivp) {
|
|
4
|
+
const eqsCount = ivp.deqs.solutionNames.length;
|
|
5
|
+
const paramsCount = (ivp.params !== null) ? ivp.params.size : 0;
|
|
6
|
+
const loopParamsCount = (ivp.loop !== null) ? LOOP_PARAMS_CONT : 0;
|
|
7
|
+
const size = ARG_INP_COUNT + eqsCount + paramsCount + loopParamsCount;
|
|
8
|
+
const inputVector = new Float64Array(size);
|
|
9
|
+
// Argument
|
|
10
|
+
argName2IdxMap.forEach((index, key) => {
|
|
11
|
+
if (key in inputs)
|
|
12
|
+
inputVector[index] = inputs[key];
|
|
13
|
+
else
|
|
14
|
+
throw new Error(`Inconsistent inputs: "${key}" is missing`);
|
|
15
|
+
});
|
|
16
|
+
let idx = ARG_INP_COUNT;
|
|
17
|
+
// Init values
|
|
18
|
+
ivp.deqs.solutionNames.forEach((name) => {
|
|
19
|
+
if (name in inputs)
|
|
20
|
+
inputVector[idx] = inputs[name];
|
|
21
|
+
else
|
|
22
|
+
throw new Error(`Inconsistent inputs: "${name}" is missing`);
|
|
23
|
+
++idx;
|
|
24
|
+
});
|
|
25
|
+
// Parameters
|
|
26
|
+
if (ivp.params !== null) {
|
|
27
|
+
ivp.params.forEach((_, name) => {
|
|
28
|
+
if (name in inputs)
|
|
29
|
+
inputVector[idx] = inputs[name];
|
|
30
|
+
else
|
|
31
|
+
throw new Error(`Inconsistent inputs: "${name}" is missing`);
|
|
32
|
+
++idx;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// Loop params
|
|
36
|
+
if (ivp.loop !== null) {
|
|
37
|
+
if (LOOP_COUNT_NAME in inputs)
|
|
38
|
+
inputVector[idx] = inputs[LOOP_COUNT_NAME];
|
|
39
|
+
else
|
|
40
|
+
throw new Error(`Inconsistent inputs, loop repetitions count is not defined: "${LOOP_COUNT_NAME}" is missing`);
|
|
41
|
+
++idx;
|
|
42
|
+
}
|
|
43
|
+
return inputVector;
|
|
44
|
+
} // getInputVector
|
|
45
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["input.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAE7F,0CAA0C;AAC1C,MAAM,UAAU,cAAc,CAAC,MAA8B,EAAE,GAAQ;IACrE,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAC/C,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,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E,GAAG,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC;IAED,cAAc;IACd,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtB,IAAI,eAAe,IAAI,MAAM;YAC3B,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;;YAE3C,MAAM,IAAI,KAAK,CAAC,gEAAgE,eAAe,cAAc,CAAC,CAAC;QAEjH,EAAE,GAAG,CAAC;IACR,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC,iBAAiB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {IVP} from '../scripting-tools';
|
|
2
|
+
import {ARG_INP_COUNT, argName2IdxMap, LOOP_PARAMS_CONT, LOOP_COUNT_NAME} from './constants';
|
|
3
|
+
|
|
4
|
+
/** Return inputs in a form of a vector */
|
|
5
|
+
export function getInputVector(inputs: Record<string, number>, ivp: IVP): Float64Array {
|
|
6
|
+
const eqsCount = ivp.deqs.solutionNames.length;
|
|
7
|
+
const paramsCount = (ivp.params !== null) ? ivp.params.size : 0;
|
|
8
|
+
const loopParamsCount = (ivp.loop !== null) ? LOOP_PARAMS_CONT : 0;
|
|
9
|
+
const size = ARG_INP_COUNT + eqsCount + paramsCount + loopParamsCount;
|
|
10
|
+
const inputVector = new Float64Array(size);
|
|
11
|
+
|
|
12
|
+
// Argument
|
|
13
|
+
argName2IdxMap.forEach((index, key) => {
|
|
14
|
+
if (key in inputs)
|
|
15
|
+
inputVector[index] = inputs[key];
|
|
16
|
+
else
|
|
17
|
+
throw new Error(`Inconsistent inputs: "${key}" is missing`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
let idx = ARG_INP_COUNT;
|
|
21
|
+
|
|
22
|
+
// Init values
|
|
23
|
+
ivp.deqs.solutionNames.forEach((name) => {
|
|
24
|
+
if (name in inputs)
|
|
25
|
+
inputVector[idx] = inputs[name];
|
|
26
|
+
else
|
|
27
|
+
throw new Error(`Inconsistent inputs: "${name}" is missing`);
|
|
28
|
+
|
|
29
|
+
++idx;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Parameters
|
|
33
|
+
if (ivp.params !== null) {
|
|
34
|
+
ivp.params.forEach((_, name) => {
|
|
35
|
+
if (name in inputs)
|
|
36
|
+
inputVector[idx] = inputs[name];
|
|
37
|
+
else
|
|
38
|
+
throw new Error(`Inconsistent inputs: "${name}" is missing`);
|
|
39
|
+
|
|
40
|
+
++idx;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Loop params
|
|
45
|
+
if (ivp.loop !== null) {
|
|
46
|
+
if (LOOP_COUNT_NAME in inputs)
|
|
47
|
+
inputVector[idx] = inputs[LOOP_COUNT_NAME];
|
|
48
|
+
else
|
|
49
|
+
throw new Error(`Inconsistent inputs, loop repetitions count is not defined: "${LOOP_COUNT_NAME}" is missing`);
|
|
50
|
+
|
|
51
|
+
++idx;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return inputVector;
|
|
55
|
+
} // getInputVector
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { MATH_CONSTS, MATH_FUNCS, POW_IDX } from '../scripting-tools/scripting-tools';
|
|
2
|
+
import { getOutputCode } from './output';
|
|
3
|
+
import { PipelineCreator } from './pipeline-creator';
|
|
4
|
+
import { argName2IdxMap, ARG, ARG_COL_IDX, CORRECTION_FACTOR, DEFAULT_CORRECTION, LOOP_MIN_COUNT } from './constants';
|
|
5
|
+
/** Pipeline creator for cyclic model */
|
|
6
|
+
export class CyclicModelPipelineCreator extends PipelineCreator {
|
|
7
|
+
constructor(ivp) {
|
|
8
|
+
super(ivp);
|
|
9
|
+
if (ivp.loop === null)
|
|
10
|
+
throw new Error('Incorrect use of CyclicModelPipelineCreator: model has no loop');
|
|
11
|
+
}
|
|
12
|
+
/** Return computations pipeline */
|
|
13
|
+
getPipeline(inputs) {
|
|
14
|
+
if (this.ivp.loop === null)
|
|
15
|
+
throw new Error('Incorrect use of CyclicModelPipelineCreator: model has no loop');
|
|
16
|
+
const argSize = argName2IdxMap.size;
|
|
17
|
+
const restricted = inputs.length - 1;
|
|
18
|
+
const repetitions = inputs[restricted];
|
|
19
|
+
if (repetitions < LOOP_MIN_COUNT)
|
|
20
|
+
throw new Error(`Incorrect repetitions count: ${repetitions}, expected: > 0`);
|
|
21
|
+
const preProcLines = [];
|
|
22
|
+
// Used math funcs
|
|
23
|
+
this.ivp.usedMathFuncs.forEach((idx) => {
|
|
24
|
+
if (idx !== POW_IDX)
|
|
25
|
+
preProcLines.push(`const ${MATH_FUNCS[idx]} = (x) => Math.${MATH_FUNCS[idx]}(x);`);
|
|
26
|
+
else
|
|
27
|
+
preProcLines.push(`const pow = (x, y) => Math.pow(x, y);`);
|
|
28
|
+
});
|
|
29
|
+
// Used math consts
|
|
30
|
+
this.ivp.usedMathConsts.forEach((idx) => {
|
|
31
|
+
preProcLines.push(`const ${MATH_CONSTS[idx]} = Math.${MATH_CONSTS[idx]};`);
|
|
32
|
+
});
|
|
33
|
+
// Model constants
|
|
34
|
+
if (this.ivp.consts !== null)
|
|
35
|
+
this.ivp.consts.forEach((input, name) => preProcLines.push(`const ${name} = ${input.value};`));
|
|
36
|
+
preProcLines.push(`const inputs = arguments[1].slice(0, ${restricted});`);
|
|
37
|
+
// Extract inputs
|
|
38
|
+
argName2IdxMap.forEach((idx, name) => preProcLines.push(`let ${name} = inputs[${idx}];`));
|
|
39
|
+
this.ivp.deqs.solutionNames.forEach((name, idx) => {
|
|
40
|
+
preProcLines.push(`let ${name} = inputs[${idx + argSize}];`);
|
|
41
|
+
});
|
|
42
|
+
if (this.ivp.params !== null) {
|
|
43
|
+
const shift = argSize + this.ivp.deqs.solutionNames.length;
|
|
44
|
+
let idx = 0;
|
|
45
|
+
this.ivp.params.forEach((_, name) => {
|
|
46
|
+
preProcLines.push(`let ${name} = inputs[${idx + shift}];`);
|
|
47
|
+
++idx;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// Updates
|
|
51
|
+
this.ivp.loop.updates.forEach((expr) => preProcLines.push(`${expr};`));
|
|
52
|
+
// Input vector update
|
|
53
|
+
argName2IdxMap.forEach((idx, name) => preProcLines.push(`inputs[${idx}] = ${name};`));
|
|
54
|
+
this.ivp.deqs.solutionNames.forEach((name, idx) => {
|
|
55
|
+
preProcLines.push(`inputs[${idx + argSize}] = ${name};`);
|
|
56
|
+
});
|
|
57
|
+
if (this.ivp.params !== null) {
|
|
58
|
+
const shift = argSize + this.ivp.deqs.solutionNames.length;
|
|
59
|
+
let idx = 0;
|
|
60
|
+
this.ivp.params.forEach((_, name) => {
|
|
61
|
+
preProcLines.push(`inputs[${idx + shift}] = ${name};`);
|
|
62
|
+
++idx;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
preProcLines.push(`return inputs;`);
|
|
66
|
+
const postProcLines = [
|
|
67
|
+
'const solution = arguments[0];',
|
|
68
|
+
'const lastIdx = solution[0].length - 1;',
|
|
69
|
+
'const inputs = new Float64Array(arguments[1]);',
|
|
70
|
+
`const duration = inputs[${argName2IdxMap.get(ARG.FINISH)}] - inputs[${argName2IdxMap.get(ARG.START)}];`,
|
|
71
|
+
`inputs[${argName2IdxMap.get(ARG.START)}] = inputs[${argName2IdxMap.get(ARG.FINISH)}];`,
|
|
72
|
+
`inputs[${argName2IdxMap.get(ARG.FINISH)}] += duration;`,
|
|
73
|
+
];
|
|
74
|
+
this.ivp.deqs.solutionNames.forEach((_, idx) => {
|
|
75
|
+
postProcLines.push(`inputs[${idx + argSize}] = solution[${idx + 1}][lastIdx];`);
|
|
76
|
+
});
|
|
77
|
+
postProcLines.push('return inputs;');
|
|
78
|
+
const preCode = preProcLines.join('\n');
|
|
79
|
+
const postCode = postProcLines.join('\n');
|
|
80
|
+
const wrappers = new Array(repetitions);
|
|
81
|
+
for (let i = 0; i < repetitions; ++i) {
|
|
82
|
+
wrappers[i] = {
|
|
83
|
+
preproc: preCode,
|
|
84
|
+
out: null,
|
|
85
|
+
postproc: postCode,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
wrappers[repetitions - 1].postproc = this.getArgumentCorrectionCode();
|
|
89
|
+
return {
|
|
90
|
+
wrappers: wrappers,
|
|
91
|
+
out: getOutputCode(this.ivp),
|
|
92
|
+
};
|
|
93
|
+
} // getPipeline
|
|
94
|
+
/** Return code for correction of an argument */
|
|
95
|
+
getArgumentCorrectionCode() {
|
|
96
|
+
return `const arg = arguments[0][${ARG_COL_IDX}];
|
|
97
|
+
const length = arg.length;
|
|
98
|
+
const step = arg[1] - arg[0];
|
|
99
|
+
const correction = Math.min(step * ${CORRECTION_FACTOR}, ${DEFAULT_CORRECTION});
|
|
100
|
+
for (let i = 0; i < length - 1; ++i) {
|
|
101
|
+
if (arg[i + 1] - arg[i] < step)
|
|
102
|
+
arg[i] -= correction;
|
|
103
|
+
}
|
|
104
|
+
return arguments[0];`;
|
|
105
|
+
} // getArgumentCorrectionCode
|
|
106
|
+
} // CyclicModelPipelineCreator
|
|
107
|
+
//# sourceMappingURL=loops-pipeline-creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loops-pipeline-creator.js","sourceRoot":"","sources":["loops-pipeline-creator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAC,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AAEpH,wCAAwC;AACxC,MAAM,OAAO,0BAA2B,SAAQ,eAAe;IAC7D,YAAY,GAAQ;QAClB,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,GAAG,CAAC,IAAI,KAAK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