@@ -3,58 +3,58 @@ include(joinpath(@__DIR__, "binarize.jl"))
3
3
include (joinpath (@__DIR__ , " factor.jl" ))
4
4
5
5
6
- function apply_transform (transform:: T , prob:: ODESystem ; constants:: Vector{Num} = Num[]) where T<: AbstractTransform
7
-
8
- # Factorize all model equations to generate a new set of equations
9
-
10
- genparam (get_name (prob. iv. val))
11
-
12
- equations = Equation[]
13
- for eqn in prob. eqs
14
- current = length (equations)
15
- factor (eqn. rhs, eqs= equations)
16
- if length (equations) > current
17
- push! (equations, Equation (eqn. lhs, equations[end ]. rhs))
18
- deleteat! (equations, length (equations)- 1 )
19
- else
20
- index = findall (x -> isequal (x. rhs, eqn. rhs), equations)
21
- push! (equations, Equation (eqn. lhs, equations[index[1 ]]. lhs))
22
- end
23
- end
24
-
25
- # Apply transform rules to the factored equations to make the final equation set
26
- new_equations = Equation[]
27
- for a in equations
28
- zn = var_names (transform, zstr (a))
29
- if string (xstr (a)) in string .(constants)
30
- xn = (xstr (a), xstr (a), xstr (a), xstr (a))
31
- else
32
- xn = var_names (transform, xstr (a))
33
- end
34
- if isone (arity (a))
35
- targs = (transform, op (a), zn... , xn... )
36
- else
37
- if string (ystr (a)) in string .(constants)
38
- yn = (ystr (a), ystr (a), ystr (a), ystr (a))
39
- else
40
- yn = var_names (transform, ystr (a))
41
- end
42
- targs = (transform, op (a), zn... , xn... , yn... )
43
- end
44
- new = transform_rule (targs... )
45
- for i in new
46
- push! (new_equations, i)
47
- end
48
- end
49
-
50
- # Copy model start points to the newly transformed variables
51
- var_defaults, param_defaults = translate_initial_conditions (transform, prob, new_equations)
52
-
53
- # Use the transformed equations and new start points to generate a new ODE system
54
- @named new_sys = ODESystem (new_equations, defaults= merge (var_defaults, param_defaults))
55
-
56
- return new_sys
57
- end
6
+ # function apply_transform(transform::T, prob::ODESystem; constants::Vector{Num}=Num[]) where T<:AbstractTransform
7
+
8
+ # # Factorize all model equations to generate a new set of equations
9
+
10
+ # genparam(get_name(prob.iv.val))
11
+
12
+ # equations = Equation[]
13
+ # for eqn in prob.eqs
14
+ # current = length(equations)
15
+ # factor(eqn.rhs, eqs=equations)
16
+ # if length(equations) > current
17
+ # push!(equations, Equation(eqn.lhs, equations[end].rhs))
18
+ # deleteat!(equations, length(equations)-1)
19
+ # else
20
+ # index = findall(x -> isequal(x.rhs, eqn.rhs), equations)
21
+ # push!(equations, Equation(eqn.lhs, equations[index[1]].lhs))
22
+ # end
23
+ # end
24
+
25
+ # # Apply transform rules to the factored equations to make the final equation set
26
+ # new_equations = Equation[]
27
+ # for a in equations
28
+ # zn = var_names(transform, zstr(a))
29
+ # if string(xstr(a)) in string.(constants)
30
+ # xn = (xstr(a), xstr(a), xstr(a), xstr(a))
31
+ # else
32
+ # xn = var_names(transform, xstr(a))
33
+ # end
34
+ # if isone(arity(a))
35
+ # targs = (transform, op(a), zn..., xn...)
36
+ # else
37
+ # if string(ystr(a)) in string.(constants)
38
+ # yn = (ystr(a), ystr(a), ystr(a), ystr(a))
39
+ # else
40
+ # yn = var_names(transform, ystr(a))
41
+ # end
42
+ # targs = (transform, op(a), zn..., xn..., yn...)
43
+ # end
44
+ # new = transform_rule(targs...)
45
+ # for i in new
46
+ # push!(new_equations, i)
47
+ # end
48
+ # end
49
+
50
+ # # Copy model start points to the newly transformed variables
51
+ # var_defaults, param_defaults = translate_initial_conditions(transform, prob, new_equations)
52
+
53
+ # # Use the transformed equations and new start points to generate a new ODE system
54
+ # @named new_sys = ODESystem(new_equations, defaults=merge(var_defaults, param_defaults))
55
+
56
+ # return new_sys
57
+ # end
58
58
59
59
function apply_transform (transform:: T , eqn_vector:: Vector{Equation} ; constants:: Vector{Num} = Num[]) where T<: AbstractTransform
60
60
0 commit comments