-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdaecore-types.mc
71 lines (54 loc) · 2.03 KB
/
daecore-types.mc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
include "./lib/vec.mc"
include "./lib/mat.mc"
-- A tuple `(id, ord)` representing a dependent variable `id` at the
-- differentiation order `ord` w.r.t. the free variable. `id` is assumed to be
-- in the range [0, n-1], where n is the size of the DAE equation.
type IdOrd = (Int, Int)
let cmpIdOrd = lam x : IdOrd. lam y : IdOrd.
match (x, y) with ((id1, ord1), (id2, ord2)) in
if eqi id1 id2 then subi ord1 ord2
else subi id1 id2
type EqnStructure = {
-- Variables at the given differential order present in this equation.
variables : [IdOrd],
-- Inputs present in this equation
inputs : [Int]
}
-- A non-existent incidence in the sigma matrix.
let daecoreSigmaNoEdge = negi 100000
type DAEStructureLowIndex = {
-- Encodes weighted incidence between variables (columns) and equations
-- (rows), where the weights are the derivative order of the variable.
sigma : Matrix Int,
-- Equation offset vector which indicates the number of times the equation
-- corresponding to each index needs to be differentiated in order to reduce
-- the index to one or less.
c : Vector Int,
-- Variable offset vector which indicates the highest derivative order of the
-- variables corresponding to each index.
d : Vector Int,
-- Input offset vector which indicated the highest derivative order of the
-- inputs in the index reduced DAE.
e : Vector Int,
-- Indicates a matching between variables (index) and equations (values) in
-- the index reduced DAE mode.
varToEq : Vector Int
}
type DAEStructureLowIndexStable = {
-- see `DAEStructureLowIndexRec`
d : Vector Int,
-- see `DAEStructureLowIndexRec`
e : Vector Int,
-- A vector indicating algebraic variables substituted for their derivatives.
lambda : Vector Int,
-- The number of dummy variables.
nmu : Int,
-- Non-differentiated differential equations.
eqns0d : [Int],
-- Non-differentiated algebraic equations.
eqns0a : [Int],
-- Non-Differentiated constraint equations.
eqns0c : [Int],
-- Differentiated constraint equations.
eqnsNc : [IdOrd]
}