gpt4 book ai didi

wolfram-mathematica - 数学 : help solving a system of non-linear equations with inequality constraints

转载 作者:行者123 更新时间:2023-12-04 08:07:17 26 4
gpt4 key购买 nike

我有一个包含 4 个未知数的 4 个非线性方程组。另外我有 1 个不等式约束,我需要四个未知数的函数来满足(然后我需要四个未知数是非负的)。我的问题有 12 个左右的参数,我打算最终解决一系列参数的问题,以查看解决方案的行为方式。并非下面代码中包含的所有参数都用于此特定设置(它们用于其他设置)。我知道我的系统可能没有所有参数值的解决方案,我需要做一些工作来找到有效的参数空间,但在我这样做之前,我需要知道如何求解非线性方程组不平等约束。我是 Mathematica 的新手,我在下面包含了我的代码。在代码中,我首先给出了一些参数值,然后我定义了一些系数,然后我在 FindInstance 函数中编写了 4 个方程和 1 个不等式(这不起作用)。我已经使用 FindRoot 函数针对一组特定的参数求解了这 4 个方程,但我得到的解不满足不等式。非常感谢。 Mathematica 中的代码如下:

    values = {{r, \[Delta], \[Sigma], Subscript[i, e], Subscript[i, u], 
Subscript[\[Lambda], e ], Subscript[\[Lambda], u ], Subscript[H,
0], Subscript[C, f] , F, \[Tau], Subscript[C, Ren]}, {0.047, 0.05,
0.1632, 5, 0, 0.005, 0.02, 100, 17, 80, 0.3, 8}};
G = Grid[values,
Dividers -> {{None, None, None}, {{Blue}, {Blue}, None}}];
r = values[[2, 1]];
\[Delta] = values[[2, 2]];
\[Sigma] = values[[2, 3]];
Subscript[i, e] = values[[2, 4]];
Subscript[i, u] = values[[2, 5]];
Subscript[\[Lambda], e] = values[[2, 6]];
Subscript[\[Lambda], u] = values[[2, 7]];
Subscript[H, 0] = values[[2, 8]];
Subscript[C, f] = values[[2, 9]];
F = values[[2, 10]];
\[Tau] = values[[2, 11]];
Subscript[C, Ren] = values[[2, 12]];
Subscript[I, e] =
Subscript[i, e]/
r - (Subscript[i, e] - Subscript[i, u]) Subscript[\[Lambda],
e]/(r (r + Subscript[\[Lambda], e] + Subscript[\[Lambda], u]));
Subscript[I, u] =
Subscript[i, u]/
r + (Subscript[i, e] - Subscript[i, u]) Subscript[\[Lambda],
u]/(r (r + Subscript[\[Lambda], e] + Subscript[\[Lambda], u]));
Solve[k (k - 1) + 2 (r - \[Delta])/\[Sigma]^2 k - 2 r/\[Sigma]^2 == 0,
k];
{Subscript[k, 1 ], Subscript[k, 2 ]} = k /. % ;
Clear[k];
Subscript[k, 1]
Subscript[k, 2]
L1 = (H1S^(-Subscript[k, 1])* (F - (c1*F)/r + (
H1S^(Subscript[k, 2])*((F* H1D^(Subscript[k, 1])* (-c1 + r))/r +
H1S^(Subscript[k, 1])*(-(c0* F)/r + (c1*F)/
r + (H1D^(Subscript[k,
2])*(-F*H0D^(Subscript[k, 1])* (c0 - r) +
H0S^(Subscript[k, 1])* (c0*F - H0D *r +
r* Subscript[C, f])))/((H0D^(Subscript[k, 2])*
H0S^(Subscript[k, 1]) -
H0D^(Subscript[k, 1])* H0S^(Subscript[k, 2]))*
r) + (H1D^(Subscript[k,
1])*(F*H0D^(Subscript[k, 2])*(c0 - r) -
H0S^(Subscript[k, 2])* (c0*F - H0D* r +
r* Subscript[C, f])))/((H0D^(Subscript[k, 2])*
H0S^(Subscript[k, 1]) -
H0D^(Subscript[k, 1])* H0S^(Subscript[k, 2]))*r) +
Subscript[C, Ren])))/(
H1D^(Subscript[k, 2])* H1S^(Subscript[k, 1]) -
H1D^(Subscript[k, 1])* H1S^(Subscript[k, 2]))));
M1 = (((F* H1D^(Subscript[k, 1])* (-c1 + r))/r +
H1S^(Subscript[k, 1])*(-(c0* F)/r + (c1*F)/
r + (H1D^(Subscript[k,
2])*(-F*H0D^(Subscript[k, 1])* (c0 - r) +
H0S^(Subscript[k, 1])* (c0*F - H0D *r +
r* Subscript[C, f])))/((H0D^(Subscript[k, 2])*
H0S^(Subscript[k, 1]) -
H0D^(Subscript[k, 1])* H0S^(Subscript[k, 2]))*
r) + (H1D^(Subscript[k,
1])*(F*H0D^(Subscript[k, 2])*(c0 - r) -
H0S^(Subscript[k, 2])* (c0*F - H0D* r +
r* Subscript[C, f])))/((H0D^(Subscript[k, 2])*
H0S^(Subscript[k, 1]) -
H0D^(Subscript[k, 1])* H0S^(Subscript[k, 2]))*r) +
Subscript[C, Ren]))/(
H1D^(Subscript[k, 2])* H1S^(Subscript[k, 1]) -
H1D^(Subscript[k, 1])* H1S^(Subscript[k, 2])));
L0 = ((-F*H0D^(Subscript[k, 2])*(c0 - r) +
H0S^(Subscript[k, 2])*(c0*F - H0D*r +
r*Subscript[C, f]))/((H0D^(Subscript[k, 2])*
H0S^(Subscript[k, 1]) -
H0D^(Subscript[k, 1])* H0S^(Subscript[k, 2]))* r));
M0 = ((-F*H0D^(Subscript[k, 1])*(c0 - r) +
H0S^(Subscript[k, 1])*(c0*F - H0D*r +
r*Subscript[C, f]))/((H0D^(Subscript[k, 2])*
H0S^(Subscript[k, 1]) -
H0D^(Subscript[k, 1])* H0S^(Subscript[k, 2]))* r));
c0 = ((-F*H0D^(Subscript[k, 2])*r*Subscript[k, 1] +
H0S^(Subscript[k, 2])*
r*(-H0D + (H0D + Subscript[C, f])*Subscript[k, 1]))/(
F*(H0D^(Subscript[k, 2]) - H0S^(Subscript[k, 2]))*(-1 + \[Tau])*
Subscript[k, 1]));
c1 = (H1D^(Subscript[k, 1])*H1S^(Subscript[k, 1])*
r*(-1* F*H1S^(-Subscript[k, 1]) +
H1D^(-Subscript[k, 1]) *Subscript[C, Ren] + (
F*H1D^(-Subscript[k, 1])* (1 - \[Tau])*(-80*
H0D^(Subscript[k, 2])*Subscript[k, 1] +
H0S^(Subscript[k,
2])*(- H0D + (15 + H0D)* Subscript[k, 1])))/((-56*
H0D^(Subscript[k, 2]) + 56*H0S^(Subscript[k, 2]))*Subscript[
k, 1]) + (
F*H0S^(-Subscript[k,
1])*(r + ((1 - \[Tau])* (-80* H0D^(Subscript[k, 2])* r*
Subscript[k, 1] +
H0S^(Subscript[k, 2])*
r* (-H0D + (15 + H0D)*Subscript[k, 1])))/((-56*
H0D^(Subscript[k, 2]) + 56* H0S^(Subscript[k, 2]))*
Subscript[k, 1])))/r))/(
F *(H1S^(Subscript[k, 1]) - H1D^(Subscript[k, 1]))*(1 - \[Tau]));
A1 = (F*H1S^(-Subscript[k, 1])*(r + c1*(-1 + \[Tau]))*Subscript[k,
2])/(r *(Subscript[k, 1] - Subscript[k, 2]));
B1 = (F*H1S^(-Subscript[k, 2])*(r + c1*(-1 + \[Tau]))*Subscript[k,
1])/(r *(Subscript[k, 2] - Subscript[k, 1]));

FindInstance[
L1*Subscript[H, 0]^(Subscript[k, 1]) +
M1*Subscript[H, 0]^Subscript[k, 2] + c1*F/r == F &&
L0*H1D^(Subscript[k, 1]) + M0*H1D^Subscript[k, 2] + c0*F/r -
Subscript[C, Ren] ==
H1D - Subscript[C,
f] && (F*H0S^(-Subscript[k, 1])*(r + c0*(-1 + \[Tau]))* Subscript[
k, 2]) == (H0D^(-Subscript[k, 1])*(-H0D*
r + (H0D*r + c0*F *(-1 + \[Tau]) + r* Subscript[C, f])*
Subscript[k, 2])) && (F*
H1S^(-Subscript[k, 2])*(r + c1*(-1 + \[Tau]))*Subscript[k,
1]) == (H0S^(-Subscript[k, 2])*
H1D^(-Subscript[k, 2])*((-c0 + c1)*F*
H0S^(Subscript[k, 2])*(-1 + \[Tau]) +
F*H1D^(Subscript[k, 2])* (c0 + r - c0 *\[Tau]) +
H0S^(Subscript[k, 2])* r* Subscript[C, Ren])* Subscript[k,
1]) && A1*(Subscript[H, 0])^(Subscript[k, 1]) +
B1*(Subscript[H, 0])^(Subscript[k, 2]) + (H1S) - (1 - \[Tau])*c1*
F/r > 0 && H1S > 0 && H0S > 0 && H1D > 0 && H0D > 0, {H1S, H0S,
H1D, H0D}, Reals]
Clear[c0, c1, L0, L1, M0, M1, H1D, H0D, H1S, H0S]

最佳答案

我认为您不能在有约束(不等式等)的情况下使用 FindRoot。对于非线性约束优化,您需要研究以下内置函数

  • 最大化[...]
  • N最大化[...]
  • 查找最大值[...]
  • 最小化[...]
  • N最小化[...]
  • 求最小值[...]

我不确定您需要哪一个来解决这个特定问题。

下面是一个 Maximize 的例子:

Maximize[{(2 x + y - z)/(5 x - 7 y + 3), 
0 <= x + y + z <= 1 && 1 <= x - y + z <= 2 && x - y - z == 3}, {x,
y, z}]

给出以下输出:

{5/13, {x -> 2, y -> 0, z -> -1}}

有关 Mathematica 中约束优化(包括非线性变量)的更多信息,请访问以下链接:

希望对您有所帮助。

关于wolfram-mathematica - 数学 : help solving a system of non-linear equations with inequality constraints,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5918928/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com