Wolfram mathematica 使用ParameterCndSolve迭代运行参数集列表
所以我有下面的代码Wolfram mathematica 使用ParameterCndSolve迭代运行参数集列表,wolfram-mathematica,Wolfram Mathematica,所以我有下面的代码 perturb1 = x'[t] == mu1*x[t] + x[t]*(a*x[t] + b*y[t] + c*z[t]) + x[t]*eps1 * (UnitStep[t - 1.5] - UnitStep[t - 2.5]); perturb2 = y'[t] == mu2*y[t] + y[t]*(d*x[t] + e*y[t] + f*z[t]) + y[t]*eps2 * (UnitStep[t - 1.5] - UnitStep
perturb1 =
x'[t] == mu1*x[t] + x[t]*(a*x[t] + b*y[t] + c*z[t]) +
x[t]*eps1 * (UnitStep[t - 1.5] - UnitStep[t - 2.5]);
perturb2 =
y'[t] == mu2*y[t] + y[t]*(d*x[t] + e*y[t] + f*z[t]) +
y[t]*eps2 * (UnitStep[t - 1.5] - UnitStep[t - 2.5]);
perturb3 =
z'[t] == mu3*z[t] + z[t]*(g*x[t] + h*y[t] + i*z[t]) +
z[t]*eps3 * (UnitStep[t - 1.5] - UnitStep[t - 2.5]);
perturbSol = ParametricNDSolve[
{perturb1, perturb2, perturb3, x[0] == 0.25, y[0] == 0.4,
z[0] == 0.35},
{x[t], y[t], z[t]},
{t, 0, 500},
{mu1, mu2, mu3, a, b, c, d, e, f, g, h, i, eps1, eps2, eps3}
];
Evaluate[x[t][#] /. perturbSol] & /@ parameterSets
参数集
是一个5000+个元素的列表,其形式为{mu1、mu2、mu3、a、b、c、d、e、f、g、h、i、eps1、eps2、eps3}(但带有数值)。我要做的是使用每个参数集计算参数函数。当我像上面那样做时,我得到了错误
ParametricNDSolve: Too many parameters in {mu1,mu2,mu3,a,b,c,d,e,f,g,h,i,eps1,eps2,eps3} to be filled from {{0.9,0.9,0.9,-2,-1,-1,-1,-2,-1,-1,-1,-2,-2,-2,-2}}.
因此,这似乎是因为,使用单个值,您将按如下方式计算函数:
Evaluate[x[t][0.9,0.9,0.9,-2,-1,-1,-1,-2,-1,-1,-1,-2,-2,-2,-2]/.perturbSol]
而在参数集上使用Map时,它会执行以下操作:
Evaluate[x[t][{0.9,0.9,0.9,-2,-1,-1,-1,-2,-1,-1,-1,-2,-2,-2,-2}]/.perturbSol]
i、 它将函数应用于15个参数的列表,而不是用逗号分隔的15个参数
有什么优雅的解决办法吗?我试着在#周围展平,但什么也没做(正如我所预料的那样)。我想一种方法是把#1、#2、#3等写在方括号中,但这相当混乱
有更好的方法吗
非常感谢,
很可能,你想要的是类似于
u = ParametricNDSolveValue[{perturb1, perturb2, perturb3,
x[0] == 0.25, y[0] == 0.4, z[0] == 0.35}, {x, y, z}, {t, 0,
500}, {mu1, mu2, mu3, a, b, c, d, e, f, g, h, i, eps1, eps2,
eps3}];
parameterSets = RandomReal[{-1, 1}, {3, 15}];
(u[##])[[1]][t] & @@@ parameterSets
如果你把这个贴在上面,你得到答案的可能性会增加。谢谢,我刚在你回答后删除了这个,但自从我看到你的答案后就取消了删除。我最终使用了Evaluate[Apply[x[t],参数集,{1}]/.perfersol],但我认为您的答案也应该有效。非常感谢。