From 28bdf41c298b6e2ac1b7f872d1a6ab33b3a64a97 Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Thu, 14 May 2020 20:20:46 +0530 Subject: [PATCH 1/5] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 57e2142..31b3cac 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MATLABDiffEq" uuid = "e2752cbe-bcf4-5895-8727-84ebc14a76bd" -version = "0.3.1" +version = "0.3.2" [deps] DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" From 5e73c34acf7f776d0d3aaf1c360e22d181093fb3 Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Sat, 16 May 2020 20:40:44 +0530 Subject: [PATCH 2/5] Add solver stats and linked with Destats --- src/MATLABDiffEq.jl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/MATLABDiffEq.jl b/src/MATLABDiffEq.jl index 8ebcfd6..9869dea 100644 --- a/src/MATLABDiffEq.jl +++ b/src/MATLABDiffEq.jl @@ -62,9 +62,13 @@ function DiffEqBase.__solve( eval_string("options = odeset('RelTol',reltol,'AbsTol',abstol);") algstr = string(typeof(alg).name.name) - #algstr = replace(string(typeof(alg)),"MATLABDiffEq.","") - eval_string("[t,u] = $(algstr)(diffeqf,tspan,u0,options);") + @show algstr + eval_string("mxsol = $(algstr)(diffeqf,tspan,u0,options);") + eval_string("mxsolstats = struct(mxsol.stats);") + solstats= get_variable(:mxsolstats) + eval_string("t = mxsol.x;") ts = jvector(get_mvariable(:t)) + eval_string("u = mxsol.y';") timeseries_tmp = jarray(get_mvariable(:u)) # Reshape the result if needed @@ -78,7 +82,7 @@ function DiffEqBase.__solve( end DiffEqBase.build_solution(prob,alg,ts,timeseries, - timeseries_errors = timeseries_errors) + timeseries_errors = timeseries_errors,destats=solstats) end end # module From 3e93bf2f4a9cdecf46e7a351307900b8b2884b2b Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Sat, 16 May 2020 21:00:01 +0530 Subject: [PATCH 3/5] [WIP] extend compatibility with destats --- src/MATLABDiffEq.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MATLABDiffEq.jl b/src/MATLABDiffEq.jl index 9869dea..5e6dad6 100644 --- a/src/MATLABDiffEq.jl +++ b/src/MATLABDiffEq.jl @@ -81,6 +81,11 @@ function DiffEqBase.__solve( timeseries = timeseries_tmp end + destats = DiffEqBase.DEStats(0) + + # destats.naccept = solstats["nsteps"] + # #destats.nsolve = solstats[""] + DiffEqBase.build_solution(prob,alg,ts,timeseries, timeseries_errors = timeseries_errors,destats=solstats) end From 4d84c92b6432f771f4b5e65e071bde296694fca3 Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Sat, 16 May 2020 21:57:41 +0530 Subject: [PATCH 4/5] Link solverstats to DEStats --- src/MATLABDiffEq.jl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/MATLABDiffEq.jl b/src/MATLABDiffEq.jl index 5e6dad6..a917791 100644 --- a/src/MATLABDiffEq.jl +++ b/src/MATLABDiffEq.jl @@ -62,10 +62,9 @@ function DiffEqBase.__solve( eval_string("options = odeset('RelTol',reltol,'AbsTol',abstol);") algstr = string(typeof(alg).name.name) - @show algstr eval_string("mxsol = $(algstr)(diffeqf,tspan,u0,options);") eval_string("mxsolstats = struct(mxsol.stats);") - solstats= get_variable(:mxsolstats) + solstats = get_variable(:mxsolstats) eval_string("t = mxsol.x;") ts = jvector(get_mvariable(:t)) eval_string("u = mxsol.y';") @@ -81,13 +80,21 @@ function DiffEqBase.__solve( timeseries = timeseries_tmp end - destats = DiffEqBase.DEStats(0) - - # destats.naccept = solstats["nsteps"] - # #destats.nsolve = solstats[""] + destats = buildDEStats(solstats) DiffEqBase.build_solution(prob,alg,ts,timeseries, - timeseries_errors = timeseries_errors,destats=solstats) + timeseries_errors = timeseries_errors,destats = destats) +end + +function buildDEStats(solverstats::Dict) + + destats = DiffEqBase.DEStats(0) + destats.nf = if (haskey(solverstats, "nfevals")) solverstats["nfevals"] else 0 end + destats.nreject = if (haskey(solverstats, "nfailed")) solverstats["nfailed"] else 0 end + destats.naccept = if (haskey(solverstats, "nsteps")) solverstats["nsteps"] else 0 end + destats.nsolve = if (haskey(solverstats, "nsolves")) solverstats["nsolves"] else 0 end + destats.njacs = if (haskey(solverstats, "npds")) solverstats["npds"] else 0 end + destats end end # module From 6e63c4ba9768d754eeeccc0e72644f95f1dd124a Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Sun, 17 May 2020 00:12:06 +0530 Subject: [PATCH 5/5] Add LU decomposition in DEStats --- src/MATLABDiffEq.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MATLABDiffEq.jl b/src/MATLABDiffEq.jl index a917791..218b013 100644 --- a/src/MATLABDiffEq.jl +++ b/src/MATLABDiffEq.jl @@ -94,6 +94,7 @@ function buildDEStats(solverstats::Dict) destats.naccept = if (haskey(solverstats, "nsteps")) solverstats["nsteps"] else 0 end destats.nsolve = if (haskey(solverstats, "nsolves")) solverstats["nsolves"] else 0 end destats.njacs = if (haskey(solverstats, "npds")) solverstats["npds"] else 0 end + destats.nw = if (haskey(solverstats, "ndecomps")) solverstats["ndecomps"] else 0 end destats end