Matrix-defined differential equation with perturbation error


#1

I’m getting error ERROR: LoadError: Failed to precompile MacroTools to C:\Users\LocalUser.julia\lib\v0.6\MacroTools.ji.

Code:


dt = CSV.read("C:/.../test.csv");

M = Array(dt[:,2:12]);

mu = Array(dt[:,13]);

eps = Array(dt[:,13]);

tspan = (0.0,300.0);

function u(t,tau)
    if t>tau
        return 1
    end
    return 0
end

using DifferentialEquations

x0 = ones(mu)/10;

f(x,p,t) = mu.*x + x.*(M*x) + eps.*x * (u(t,1.5)-u(t,2.5))

prob = ODEProblem(f,x0,tspan)
sol = solve(prob)
using Plots; plot(sol)```

test.csv is this:


```Species,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,mu,eps
x1,-0.20516,0.098398,0.16739,-0.16461,-0.14341,0.019881,-0.51535,-0.39162,0.34635,0.0088853,-0.26894,0.36807,-3.2926
x2,0.062123,-0.10489,-0.043011,-0.15466,-0.1872,0.027031,-0.45919,-0.41388,0.3013,0.022081,-0.19657,0.31023,-3.0354
x3,0.14373,-0.19203,-0.10162,-0.13971,-0.16537,0.013651,-0.50414,-0.7724,0.29257,-0.005959,-0.20645,0.3561,-2.0909
x4,0.22403,0.13813,0.00045883,-0.83125,-0.2238,0.22027,-0.20529,-1.0097,0.66639,-0.038986,-0.40032,0.54006,-1.9395
x5,-0.18016,-0.051261,-5.03E-05,-0.054212,-0.70858,0.016198,-0.50756,0.55363,0.15757,0.22438,0.10635,0.70898,-1.3491
x6,-0.11159,-0.03721,-0.042591,0.041044,0.26134,-0.42266,-0.18536,-0.43231,0.1647,-0.061038,-0.26461,0.47064,-1.1018
x7,-0.12669,-0.18576,-0.12222,0.3809,0.4003,-0.16078,-1.2124,1.3897,-0.37922,0.19189,-0.096352,0.2297,-0.92446
x8,-0.071257,0.00060448,0.080355,-0.4548,-0.50349,0.16899,-0.56222,-4.3508,0.44315,-0.22341,-0.2074,0.83005,-0.79401
x9,-0.037541,-0.033333,-0.049912,-0.090424,-0.10211,0.03229,-0.18179,-0.30301,-0.055765,0.01436,-0.0076697,0.39181,-0.31272
x10,-0.04225,-0.013105,0.02398,-0.11784,-0.32893,0.020748,0.054767,-2.0963,0.11124,-0.19213,0.023816,0.29075,1.0671
x11,-0.3742,0.27843,0.24887,-0.16829,0.08399,0.033691,-0.23242,-0.39513,0.31454,-0.038764,-0.3841,0.32367,3.7009

I really don’t know much about Julia at all, only been using it a couple of days and wanted to try a lotka volterra system with defined parameters. I get the below error when running this:

fatal: error thrown and no exception handler available.

signal (22): SIGABRT
while loading C:\Users\LocalUser\.julia\v0.6\DiffEqOperators\src\DiffEqOperators.jl, in expression starting on line 0
jl_critical_error at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libjulia.dll (unknown line)
raise at C:\WINDOWS\System32\msvcrt.dll (unknown line)
abort at C:\WINDOWS\System32\msvcrt.dll (unknown line)
ZN9__gnu_cxx27__verbose_terminate_handlerEv at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libstdc++-6.dll (unknown line)
_cxa_demangle at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libstdc++-6.dll (unknown line)
ZSt9terminatev at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libstdc++-6.dll (unknown line)
_cxa_throw at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libstdc++-6.dll (unknown line)
Znwy at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libstdc++-6.dll (unknown line)
ZNSt6vectorIN4llvm28DWARFAbbreviationDeclarationESaIS1_EE19_M_emplace_back_auxIJS1_EEEvDpOT_ at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm31DWARFAbbreviationDeclarationSet7extractENS_13DataExtractorEPj at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm16DWARFDebugAbbrev7extractENS_13DataExtractorE at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm12DWARFContext26getLineInfoForAddressRangeEyyNS_19DILineInfoSpecifierE at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm20DWARFUnitSectionBase5parseERNS_12DWARFContextERKNS_12DWARFSectionE at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm17DWARFDebugAranges8generateEPNS_12DWARFContextE at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm20DWARFContextInMemory6anchorEv at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm12DWARFContext24getCompileUnitForAddressEy at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
ZN4llvm12DWARFContext25getInliningInfoForAddressEyNS_19DILineInfoSpecifierE at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\LLVM.dll (unknown line)
jl_dump_asm_internal at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libjulia.dll (unknown line)
jl_getFunctionInfo at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libjulia.dll (unknown line)
jl_gdblookup at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libjulia.dll (unknown line)
jlbacktrace at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libjulia.dll (unknown line)
jl_no_exc_handler at C:\Users\LocalUser\AppData\Local\Julia-0.6.2\bin\libjulia.dll (unknown line)
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
ERROR: LoadError: Failed to precompile DiffEqOperators to C:\Users\LocalUser\.julia\lib\v0.6\DiffEqOperators.ji.
Stacktrace:
 [1] compilecache(::String) at .\loading.jl:710
 [2] _require(::Symbol) at .\loading.jl:463
 [3] require(::Symbol) at .\loading.jl:405
 [4] include_from_node1(::String) at .\loading.jl:576
 [5] include(::String) at .\sysimg.jl:14
 [6] anonymous at .\<missing>:2
while loading C:\Users\LocalUser\.julia\v0.6\OrdinaryDiffEq\src\OrdinaryDiffEq.jl, in expression starting on line 18
ERROR: LoadError: Failed to precompile OrdinaryDiffEq to C:\Users\LocalUser\.julia\lib\v0.6\OrdinaryDiffEq.ji.
Stacktrace:
 [1] compilecache(::String) at .\loading.jl:710
 [2] _require(::Symbol) at .\loading.jl:463
 [3] require(::Symbol) at .\loading.jl:405
 [4] include_from_node1(::String) at .\loading.jl:576
 [5] include(::String) at .\sysimg.jl:14
 [6] anonymous at .\<missing>:2
while loading C:\Users\LocalUser\.julia\v0.6\DiffEqCallbacks\src\DiffEqCallbacks.jl, in expression starting on line 9
ERROR: LoadError: Failed to precompile DiffEqCallbacks to C:\Users\LocalUser\.julia\lib\v0.6\DiffEqCallbacks.ji.
Stacktrace:
 [1] compilecache(::String) at .\loading.jl:710
 [2] _require(::Symbol) at .\loading.jl:463
 [3] require(::Symbol) at .\loading.jl:405
 [4] _include_from_serialized(::String) at .\loading.jl:157
 [5] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at .\loading.jl:200
 [6] _require_search_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at .\loading.jl:236
 [7] _require(::Symbol) at .\loading.jl:441
 [8] require(::Symbol) at .\loading.jl:405
 [9] include_from_node1(::String) at .\loading.jl:576
 [10] include(::String) at .\sysimg.jl:14
 [11] anonymous at .\<missing>:2
while loading C:\Users\LocalUser\.julia\v0.6\DifferentialEquations\src\DifferentialEquations.jl, in expression starting on line 12

#2

This seems like a package versioning problem. Check Pkg.status(): do you have the latest versions like DifferentialEquations.jl v4.5.0?

And just to mention a few things. I would do:

u(t,tau) = ifelse(t>tau,1,0)

to speed up that tidbit, and then set tstops:

sol = solve(prob,tstops = [1.5,2.5])

to perfectly resolve the discontinuities.


#3

Thanks for the tips.

As for versions,

DifferentialEquations is 4.5.0
DiffEqOperators is 1.3.0
OrdinaryDiffEq is 3.16.1
DiffEqCallbacks is 1.1.0

Anything look wrong with that? The only other packages I’ve installed are Plots, CSV and IJulia.


#4

Hmm, I’m running the code and it’s working just fine. Did you use the generic binary from https://julialang.org/downloads/ or did you do something different like build from source?