Skip to content

Instantly share code, notes, and snippets.

(@JuliaPro_v1.5.0-1) pkg> test Pumas
Testing Pumas
Status `C:\Users\patri\AppData\Local\Temp\jl_REwB9j\Project.toml`
[0bf59076] AdvancedHMC v0.2.25
[336ed68f] CSV v0.7.7
[a93c6f00] DataFrames v0.21.6
[82cc6244] DataInterpolations v3.1.3
[864edb3b] DataStructures v0.17.20
[bcd4f6db] DelayDiffEq v5.24.1
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.5.0 (2020-08-01)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Random
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.2 (2020-05-23)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Random
julia> @code_warntype Pumas.vpc(pkres.model, pkres.data, coef(pkres), 1)
Variables
#self#::Core.Compiler.Const(Pumas.vpc, false)
m::PumasModel{ParamSet{NamedTuple{(:tvcl, :tvv, :pmoncl, :Ω, :σ_prop),Tuple{RealDomain{Int64,TransformVariables.Infinity{true},Float64},RealDomain{Int64,TransformVariables.Infinity{true},Float64},RealDomain{Float64,TransformVariables.Infinity{true},Float64},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}},var"#3#12",var"#4#13",var"#5#15",Central1,var"#6#16",var"#9#19"}
population::Array{Subject{NamedTuple{(:dv,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:isPM, :wt),Tuple{Int64,Int64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1},Pumas.ConstantCovar{NamedTuple{(:isPM, :wt),Tuple{Int64,Int64}}},Float64},1}
param::NamedTuple{(:tvcl, :tvv, :pmoncl, :Ω, :σ_prop),Tuple{Float64,Float64,Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},Float64}}
reps::Int
This file has been truncated, but you can view the full file.
julia> o_ode = fit(iv_ode,data,param,Pumas.FOCEI())
ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{getfield(Pumas, Symbol("##176#181")){Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(Pumas, Symbol("##175#180")){Float64,Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},PumasModel{ParamSet{NamedTuple{(:tvcl, :tvv, :dur, :Ω, :σ_prop),Tuple{RealDomain{Float64},RealDomain{Float64},RealDomain{Float64},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64}}}},getfield(Main, Symbol("##53#58")),getfield(Main, Symbol("##54#59")),getfield(Main, Symbol("##55#60")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(ModelingToolkit, Symbol("#out_f_safe#66")){getfield(ModelingToolkit, Symbol("###396"))},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Nothing,DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##56#61")),getfield(Main, Symbol("##57#62"))},Subject{NamedTupl
using StaticArrays
using NLSolvers
using LinearAlgebra
function himmelblau(∇²f, ∇f, x)
if !(∇²f == nothing)
∇²f11 = 12.0 * x[1]^2 + 4.0 * x[2] - 42.0
∇²f12 = 4.0 * x[1] + 4.0 * x[2]
∇²f21 = 4.0 * x[1] + 4.0 * x[2]
∇²f22 = 12.0 * x[2]^2 + 4.0 * x[1] - 26.0
∇²f = @SMatrix([∇²f11 ∇²f12; ∇²f21 ∇²f22])
from HARK.ConsumptionSaving.ConsIndShockModel import IndShockConsumerType
import HARK.ConsumptionSaving.ConsumerParameters as param
import copy
init_lifecycle = copy.copy(param.init_idiosyncratic_shocks)
init_lifecycle['PermGroFac'] = [1.01, 1.00]
init_lifecycle['PermShkStd'] = [0.1, 0.0]
init_lifecycle['TranShkStd'] = [0.3,0.0]
init_lifecycle['LivPrb'] = [0.99,0.9]
init_lifecycle['T_cycle'] = 2
0.000004 seconds (5 allocations: 144 bytes)
Body::Tuple{Float64,Float64,Bool}
1 ── %1 = (Base.getfield)(opt, :ratio)::Float64
│ %2 = (Base.getfield)(opt, :c)::Float64
│ %3 = (Base.getfield)(opt, :ls_max_iter)::Int64
│ %4 = (Base.getfield)(d, :data)::Tuple{Float64,Float64}
│ %5 = (Base.getfield)(%4, 1, false)::Float64
│ %6 = (Base.getfield)(∇f_x, :data)::Tuple{Float64,Float64}
│ %7 = (Base.getfield)(%6, 1, false)::Float64
│ %8 = (Base.mul_float)(%5, %7)::Float64
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.0.2 (2018-11-08)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Optim
I just spent half a day wondering why my Jacobians were wrong, and didn't even think to look at `I`'s role, but is this not super weird?
```
julia> versioninfo()
Julia Version 0.6.4
Commit 9d11f62bcb (2018-07-09 19:09 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD Ryzen 3 1200 Quad-Core Processor
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Zen MAX_THREADS=16)