The following causes a crash in Julia v 1.6
using ModelingToolkit, NonlinearSolve, Plots
@variables c, ℓ, L, K, Y, Π, v, r, w
@parameters αK, αL, γ, EH, EK
F(K,L,αK, αL) = (K^αK)*(L^αL)
FK(K,L,αK,αL) = αK*(K^(αK-1.0))*(L^αL)
FL(K,L,αK,αL) = αL*(K^αK)*(L^(αL-1.0))
U(c,ℓ,γ) = γ*log(c) + (1.0 -γ)*log(ℓ)
Uc(c,ℓ,γ) = γ/c
Uℓ(c,ℓ,γ) = (1.0 -γ)/ℓ
eqs = [
0.0 ~ r - FK(K,L,αK,αL), # r = F_K
0.0 ~ w - FL(K,L,αK,αL), # w = F_L
0.0 ~ Y - F(K,L,αK, αL), # Y = F(K,L)
0.0 ~ Π - (Y- r*K - w*L), # Π = Y -rK -wL
#
0.0 ~ Uc(c,ℓ,γ)/Uℓ(c,ℓ,γ) - 1/w, # Uc/Uℓ = 1/w MRS = price ratio
0.0 ~ c + w*ℓ - (w*EH + r*K + Π), # BC
0.0 ~ EH - L - ℓ, # ℓ = EH - L
0.0 ~ EK - K,
0.0 ~ v - U(c,ℓ,γ), # value function
#
0.0 ~ c - Y, # c = Y
]
ns = NonlinearSystem(eqs, [c, ℓ, L, K, Y, Π, v, r, w,], [αK, αL, γ, EH, EK,])
guess = [c => 1.0, ℓ => 1.0, L => 1.0, K => 1.0, Y => 1.0, Π => 1.0, v =>1.0, r => 1.0, w => 1.0]
ps = [ αK => 0.45; αL => 0.5; γ => 0.5; EH => 24.0; EK => 10.0;]
prob = NonlinearProblem(ns,guess,ps)
sol = solve(prob,NewtonRaphson())
#c, ℓ, L, K, Y, Π, v, r, w = tuple(sol...)
Crash occurs at solve()
Crash message:
The terminal process
“C:\Users\azevelev\AppData\Local\Programs\Julia-1.6.0\bin\julia.exe ‘-i’, ‘–banner=no’, ‘–project=C:\Users\azevelev.julia\environments\v1.6’, ‘c:\Users\azevelev.vscode\extensions\julialang.language-julia-1.1.37\scripts\terminalserver\terminalserver.jl’, ‘\.\pipe\vsc-jl-repl-95aefdc3-19e2-4af6-b729-7a88dcfed920’, ‘\.\pipe\vsc-jl-cr-0dc6ed39-f5cb-40b5-bbb6-83e0abb7fcb3’, ‘USE_REVISE=true’, ‘USE_PLOTPANE=true’, ‘USE_PROGRESS=true’, ‘DEBUG_MODE=undefined’”
terminated with exit code: 1.