In [31]:
import sympy as sp
古诺模型¶
纳什均衡
$$ \pi_1=q_1 * (D - (q_1+q_2)) - q_1*c\\ \pi_2=q_2 * (D - (q_1+q_2)) - q_2*c $$ $$ \downarrow $$ $$ \begin{cases} \frac{\partial\pi_1}{q_1}=0\\ \frac{\partial\pi_2}{q_2}=0 \end{cases} $$ $$ \downarrow $$ $$ q_1^*=q_2^*=\frac {D-c}3,\pi_0^*=\frac{2(D-c)^2}{9} $$
In [34]:
D, c = sp.symbols('D, c')
q1, q2 = sp.symbols('q1, q2')
pi1 = q1 * (D - (q1 + q2)) - q1 * c
pi2 = q2 * (D - (q1 + q2)) - q2 * c
pi1_derivative_q1 = sp.diff(pi1, q1)
pi2_derivative_q2 = sp.diff(pi2, q2)
solution = sp.solve([pi1_derivative_q1, pi2_derivative_q2], [q1, q2])
print(solution)
pi0 = pi1 + pi2
pi0_optimal = pi0.subs(solution)
pi0_optimal = sp.simplify(pi0_optimal)
pi0_optimal
{q1: D/3 - c/3, q2: D/3 - c/3}
Out[34]:
$\displaystyle \frac{2 \left(D - c\right)^{2}}{9}$
合作状态
$$ \pi_0 = q * (D - q) - q*c $$ $$ \downarrow $$ $$ \frac{\partial \pi_0}{\partial q}=0 $$ $$ \downarrow $$ $$ q^*=\frac{D-c}{2},\pi_0^*=\frac{(D-c)^2}{4} $$
In [35]:
q = sp.symbols('q')
pi0 = q * (D - q) - q * c
pi0_derivative_q = sp.diff(pi0, q)
solution = sp.solve([pi0_derivative_q], [q])
print(solution)
pi0_optimal = pi0.subs(solution)
pi0_optimal = sp.simplify(pi0_optimal)
pi0_optimal
{q: D/2 - c/2}
Out[35]:
$\displaystyle \frac{\left(D - c\right)^{2}}{4}$
In [44]:
q1, q2 = sp.symbols('q_1, q_2')
D, c = sp.symbols('D, c')
q1_ = sp.symbols('q_1^*') # 甲先定 q_1^*
pi2 = q2 * (D - (q1_ + q2)) - q2 * c
pi2
Out[44]:
$\displaystyle - c q_{2} + q_{2} \left(D - q^{*}_{1} - q_{2}\right)$
In [60]:
pi2_derivative_q2 = sp.diff(pi2, q2)
solution = sp.solve([pi2_derivative_q2], [q2])
q2_optimal = solution[q2]
pi2_optimal = pi2.subs(solution)
pi2_optimal = sp.simplify(pi2_optimal)
pi2_optimal
Out[60]:
$\displaystyle \frac{\left(- D + c + q^{*}_{1}\right)^{2}}{4}$
再到甲
In [63]:
pi1 = q1_ * (D - (q1_ + q2_optimal)) - q1_ * c
pi1
Out[63]:
$\displaystyle - c q^{*}_{1} + q^{*}_{1} \left(\frac{D}{2} + \frac{c}{2} - \frac{q^{*}_{1}}{2}\right)$
In [67]:
pi1_derivative_q1 = sp.diff(pi1, q1_)
solution = sp.solve([pi1_derivative_q1], [q1_])
pi1_optimal = pi1.subs(solution)
pi1_optimal = sp.simplify(pi1_optimal)
pi1_optimal
Out[67]:
$\displaystyle \frac{\left(D - c\right)^{2}}{8}$
再到乙
In [71]:
pi2_optimal = sp.simplify(pi2_optimal.subs(solution))
pi2_optimal
Out[71]:
$\displaystyle \frac{\left(D - c\right)^{2}}{16}$
In [74]:
pi0 = sp.simplify(pi1_optimal+pi2_optimal)
pi0
Out[74]:
$\displaystyle \frac{3 \left(D - c\right)^{2}}{16}$