vollmersj / coexist.jl Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
sys = modelingtoolkitize(prob)
at code line
throws
ERROR: TensorOperations.IndexError{String}("invalid permutation of length 1: (1, 2, 3, 4)")
Stacktrace:
[1] contract!(::Bool, ::Array{Operation,1}, ::Symbol, ::Array{Float64,7}, ::Symbol, ::Bool, ::SubArray{Float64,3,Array{Float64,4},Tuple{Int64,Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}}},true}, ::Tuple{}, ::NTuple{4,Int64}, ::Tuple{Int64,Int64,Int64}, ::NTuple{4,Int64}, ::Tuple{Int64,Int64,Int64}, ::Tuple{Symbol,Symbol,Symbol}) at /Users/vollmer/.julia/packages/TensorOperations/PuhjE/src/implementation/stridedarray.jl:262
[2] contract!(::Bool, ::Array{Operation,1}, ::Symbol, ::Array{Float64,7}, ::Symbol, ::Bool, ::SubArray{Float64,3,Array{Float64,4},Tuple{Int64,Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}}},true}, ::Tuple{}, ::NTuple{4,Int64}, ::Tuple{Int64,Int64,Int64}, ::NTuple{4,Int64}, ::Tuple{Int64,Int64,Int64}, ::Tuple{}, ::Tuple{Symbol,Symbol,Symbol}) at /Users/vollmer/.julia/packages/TensorOperations/PuhjE/src/implementation/stridedarray.jl:85
[3] f!(::Array{Any,1}, ::Array{Operation,1}, ::Array{Any,1}, ::Operation) at /Users/vollmer/covidwarwick/coexist_julia/julia/highlevel.jl:89
[4] (::ODEFunction{true,typeof(f!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing})(::Array{Any,1}, ::Vararg{Any,N} where N) at /Users/vollmer/.julia/packages/DiffEqBase/BZxEO/src/diffeqfunction.jl:248
[5] modelingtoolkitize(::ODEProblem{Array{Float64,4},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,ODEFunction{true,typeof(f!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:p,),Tuple{Nothing}}},DiffEqBase.StandardODEProblem}) at /Users/vollmer/.julia/packages/ModelingToolkit/aKa4S/src/systems/diffeqs/modelingtoolkitize.jl:19
[6] top-level scope at none:0
I've added code to build the parameter dictionary in #26
I've made use of ReExes to extract the parameters from the source code and used Julia's meta programming to convert them into julia objects.
Please verify the working of the code and suggest if there is any better way to do it.
I wasn't able to get the RE for extracting the params whenever nested () where there (I wasn't quite able to write recursive REs to do the same), so I used a rudimentary way to extract it.
FYI, in python we make use of inspect
.
The Einstein summation does not quite capture np.einsum, see Discourse
sys = modelingtoolkitize(prob)
throws an error on
stateTensor=reshape(stateTensor_vec,(nAge, nHS, nIso, nTest))
ERROR: MethodError: no method matching Float64(::Operation)
Closest candidates are:
Float64(::T) where T<:Number at boot.jl:715
Float64(::Int8) at float.jl:60
Float64(::Int16) at float.jl:60
...
Stacktrace:
using ModelingToolkit
using DifferentialEquations
nIso=4
nTest=4
nHS=8
nAge=9
x=1
# yeah
ssize=(nAge, nHS, nIso, nTest)
function f_vec!(dstateTensor_vec,stateTensor_vec,p,t)
dstateTensor=reshape(dstateTensor_vec,(nAge, nHS, nIso, nTest))
stateTensor=reshape(stateTensor_vec,(nAge, nHS, nIso, nTest))
trTensor_complete = zeros((nAge, nHS, nIso, nTest, nHS, nIso, nTest))
for iso=1:nIso
for ag=1:nAge
for hs=1:nHS
for tst=1:nTest
for nhs=1:nHS #new health state
trTensor_complete[ag,hs,iso,tst,nhs,iso,tst]+=1.0
end
end
end
end
end
dstateTensor=zeros((nAge, nHS, nIso, nTest))
for ag=1:nAge
for hs=1:nHS
for iso=1:nIso
for tst=1:nTest
for nhs=1:nHS
for niso=1:nIso
for ntst=1:nTest
dstateTensor[ag,hs,iso,tst]+=stateTensor[1,nhs,niso,ntst,]* trTensor_complete[ag,nhs,niso,ntst,hs,iso,tst]
end
end
end
end
end
end
end
dstate[:]=reshape(dstateTensor,(nIso*nAge*nHS*nTest))
end
n=prod([ssize...])
prob = ODEProblem(f_vec!,100*ones(n),(0.0,80.0),p=nothing)
sys = modelingtoolkitize(prob)
Is the best way to pass parameter to use name tupleNamedTuple
such as
(; social_distiance= (;lockdown_lift=Date("2020-06-01")) )
We are still using โ
to test few of our methods.
trFunc_HospitalAdmission
trFunc_newInfections_Complete
trFunc_HospitalDischarge
trFunc_travelInfectionRate_ageAdjusted
'ijl,j->i'
'ijk,j->ik'
'ijkj->ijk'
'ijkl,j->i'
'ijlml->ijlm'
'iklkl->ikl'
'ijljl->ijl'
'ijkljkm->ijklm'
'...jkl->...'
'ijkl,ijklmnp->imnp'
'ijkljkl->ijkl'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.