1 | package AlgorithmicModel
|
---|
2 | model BaseModelEquations
|
---|
3 | parameter Integer n=1000;
|
---|
4 | input Real[n] u1;
|
---|
5 | input Real[n] u2;
|
---|
6 | output Real[n] y1;
|
---|
7 | output Real y2;
|
---|
8 | equation
|
---|
9 | y1=array(if u1[i] > 0 then u1[i] else u2[i] for i in 1:n);
|
---|
10 | y2=sum(y1);
|
---|
11 | end BaseModelEquations;
|
---|
12 |
|
---|
13 | model BaseModelAlgorithm
|
---|
14 | parameter Integer n=1000;
|
---|
15 | input Real[n] u1;
|
---|
16 | input Real[n] u2;
|
---|
17 | output Real[n] y1;
|
---|
18 | output Real y2;
|
---|
19 | algorithm
|
---|
20 | y1:=array(if u1[i] > 0 then u1[i] else u2[i] for i in 1:n);
|
---|
21 | y2:=sum(y1);
|
---|
22 | end BaseModelAlgorithm;
|
---|
23 |
|
---|
24 | model ExtendedModelEquations
|
---|
25 | extends BaseModelEquations(n=1000);
|
---|
26 | Real[n] v1;
|
---|
27 | equation
|
---|
28 | v1=u1 - u2;
|
---|
29 | end ExtendedModelEquations;
|
---|
30 |
|
---|
31 | model ExtendedModelAlgorithm
|
---|
32 | extends BaseModelAlgorithm(n=1000);
|
---|
33 | Real[n] v1;
|
---|
34 | algorithm
|
---|
35 | v1:=u1 - u2;
|
---|
36 | end ExtendedModelAlgorithm;
|
---|
37 |
|
---|
38 | model ExtendedModelEquations2
|
---|
39 | extends BaseModelEquations(n=1000);
|
---|
40 | Real[n] v1;
|
---|
41 | equation
|
---|
42 | for i in 1:n loop
|
---|
43 | v1[i]=u1[i] - u2[i];
|
---|
44 | end for;
|
---|
45 | end ExtendedModelEquations2;
|
---|
46 |
|
---|
47 | model ExtendedModelAlgorithm2
|
---|
48 | extends BaseModelAlgorithm(n=1000);
|
---|
49 | Real[n] v1;
|
---|
50 | algorithm
|
---|
51 | for i in 1:n loop
|
---|
52 | v1[i]:=u1[i] - u2[i];
|
---|
53 | end for;
|
---|
54 | end ExtendedModelAlgorithm2;
|
---|
55 |
|
---|
56 | end AlgorithmicModel;
|
---|