aboutsummaryrefslogtreecommitdiffstats
path: root/notes/solve_for.txt
blob: b1cf81d47a5a5bae2227f015858c1e4a71cf4650 (plain)
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

    x = a*y + c
    y = 4 * c

    solve for [c] in terms of [a, x]
        first solve for other unknowns: [y]

    x = a*(4*c) + c

    x = c * (1 + 4*a)
    c = (1 + 4*a) / x

N equations in M unknowns, P constants

    0 = x + y
    0 = y*2 + 1 - x

-----------------------------------

solve_for(self, P: Vec<String>, M: Vec<String>, Q: HashMap<String, Expr>)


returns a ModelicaModel with fixed components; equations are LHS identifier, in
    correct order, no extends, no connections, name suffixed " (rewritten)",
    components as Parameter (w/ val), Input, or Output
    

V variables
Q constants (become kwargs)
P bound vars (independent, inputs/passed, become like constants)
M unknowns (dependent, outputs)
N' total equations
N equations with unknowns

  V = Q + P + M
  check: each Q is Integer or Float     UnderSpecifiedConstant
  filter N' to get N    OverConstrained if extra equations
  check: N >= M         UnderConstrained

while len(eqns) > 0:
  1. find first eqn with single unknown, and pop it
  2. rebalance to get unknown on LHS
  3. remove unknown from unknown list

return: sort equations to match order

solve_for(var) impl for SimpleEquation => Result<SimpleEquation, String>
    check: var only on one side     VariableNotFound or NaiveImplementation
    put var on LHS
    recursively apply rules to symmetrically unwrap LHS onto RHS
    if try to unwrap Abs:           NaiveImplementation

-----------------------------------
systems of differential equations:
  will be N equations of N variables, in terms of implied time

should be no unknowns; odex thing is just varying initial equations
have JS boxes to show ranges of initial conditions