我正在尝试求解由函数“ func_bcd!”给出的方程组。 我遇到的问题是,在尝试运行下面提供的代码时,Julia会“冻结”或保持运行。
我认为这个问题与函数“ func_bcd!”中的第一个方程式有关。调用其他两个函数“ r_p_this”和“ r_m_this”。也许我以错误的方式定义了功能,但是我不确定。
非常感谢所有帮助。
最好的问候, 拉斯姆斯·达姆加德
using Distributions, Random, Cubature, NLsolve, LinearAlgebra;
Random.seed!(123); # Setting the seed
function F(x)
(1-exp(-x/2))
end;
function G(x)
min(1,x/C)
end;
function rₘ_this(x)
function rₘ_this_func(z)
min(1,x[1]*z[2]./(x[1]*z[1]+x[2]*x[3]).*pdf(Gamma(μᵤ/2,1),z[1]).*pdf(Gamma(μᵤ/2,1),z[2]))
end;
(rₘ,rₘ_error) = hcubature(rₘ_this_func,a,b,abstol=1e-8)
return rₘ
end;
function rₚ_this(x)
function rₚ_this_func(z)
min(1,(x[1]*z[2]+x[2]*x[3])./(x[1]*z[1]).*pdf(Gamma(μᵤ/2,1),z[1]).*pdf(Gamma(μᵤ/2,1),z[2]))
end;
(rₚ,rₚ_error) = hcubature(rₚ_this_func,a,b,abstol=1e-8)
return rₚ
end;
function func_bcd!(f,x)
f[1] = G(1)-G((rₚ_this(x)-rₘ_this(x))/(rₚ_this(x)+rₘ_this(x)))-x[1]
f[2] = 1-(1-x[2])*x[3]/((1-x[2])*x[3]+(1-G(1))*μᵤ)-rₘ_this(x)
f[3] = μ_bar*F((1-G(1)*μᵤ*σₚₙ)/(1-x[2])*x[1]+(1-G(1))*μᵤ)-x[1]
end;
a = [0 0];
b = [3*μᵤ 3*μᵤ];
C = 2;
μ_bar = 20;
μᵤ = 60;
σₚₙ = 0.381971;
x₀ = [0.5 0.0 2.92629];
x = nlsolve(func_bcd!, x₀)