|
| 1 | +mutable struct Variable <: AbstractEvent |
| 2 | + bev :: BaseEvent |
| 3 | + id :: UInt |
| 4 | + f :: Function |
| 5 | + x :: Taylor1 |
| 6 | + t :: Float64 |
| 7 | + function Variable(env::Environment, id::Int, f::Vector{Function}, x₀::Taylor1) |
| 8 | + new(BaseEvent(env), UInt(id), f[id], x₀, now(env)) |
| 9 | + end |
| 10 | +end |
| 11 | + |
1 | 12 | struct Continuous <: AbstractProcess |
2 | 13 | bev :: BaseEvent |
3 | | - f :: Vector{Function} |
4 | | - order :: UInt8 |
5 | | - stiff :: Bool |
6 | | - t :: Vector{Float64} |
7 | | - q :: Vector{Taylor1} |
8 | | - x :: Vector{Taylor1} |
| 14 | + vars :: Vector{Variable} |
9 | 15 | p :: Vector{Float64} |
10 | | - function Continuous(func::Function, env::Environment, q::Vector{Float64}, p::Vector{Float64}=Float64[]; order::Number=4, stiff::Bool=false) |
11 | | - cont = new(BaseEvent(env), func(), UInt8(order), stiff, Vector{Float64}(), Vector{Taylor1}(), Vector{Taylor1}(), p) |
12 | | - zero_taylor = 0*Taylor1(Float64, order+1) |
13 | | - for q₀ in q |
14 | | - push!(cont.t, now(env)) |
15 | | - push!(cont.q, q₀ + zero_taylor) |
16 | | - end |
17 | | - t₀ = now(env) + Taylor1(Float64, order+1) |
18 | | - for (i, q₀) in enumerate(q) |
19 | | - push!(cont.x, integrate(cont.f[i](t₀, cont.q, cont.p), q₀)) |
20 | | - end |
21 | | - for i in 1:order-1 |
22 | | - for (i, xᵢ) in enumerate(cont.x) |
23 | | - cont.q[i] = copy(cont.x[i]) |
24 | | - end |
25 | | - for (i, qᵢ) in enumerate(cont.q) |
26 | | - cont.x[i] = integrate(cont.f[i](t₀, cont.q, cont.p), q[i]) |
27 | | - end |
28 | | - end |
| 16 | + function Continuous(model::Function, env::Environment, x₀::Vector{Float64}, p::Vector{Float64}=Float64[]; integrator::Integrator=QSS()) |
| 17 | + cont = new(BaseEvent(env), Vector{Variable}(), p) |
| 18 | + init(env, cont, integrator, model, x₀) |
29 | 19 | cont |
30 | 20 | end |
31 | 21 | end |
|
0 commit comments