我有一个由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]
答案 0 :(得分:2)
我不相信你可以使用FindRoot
约束(不等式等)。对于非线性约束优化,您将要研究以下内置函数
我不确定你对这个特殊问题想要哪一个。
以下是最大化行动的示例:
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中约束优化的更多信息(包括非线性变量)可以在以下链接中找到:
我希望这会有所帮助。