點選檢視程式碼
import numpy as np
import pylab as plt
a = 1 - 0.2**(1/12); m = 1.109 * 10 ** 5
w3 = 17.86; w4 = 22.99
X=[]; Z=[]; N=[]
for k in np.arange(0, 1.0, 0.001):
x1 = 1.22*10**11*(1-1/(m*(1-a-0.42*k)**8*(1-a)**24*
(1/2+(1-a-k)**8*(1-a)**4)))
x2 = (1-a)**12*x1; x3 = (1-a)**12*x2
x4 = (1-a-0.42*k)**8*(1-a)**4*x3
X.append([x1, x2, x3, x4])
n = m*(1-a-0.42*k)**8*(1-a)**24*(1/2+(1-a-k)**8*(1-a)**4)*x1
N.append(n)
z = (0.42*k*w3*(1-(1-a-0.42*k)**8)/(a+0.42*k)*x3+
k*w4*(1-(1-a-k)**8)/(a+k)*x4)
Z.append(z)
mz = max(np.array(Z)); ind = np.argmax(Z)
k4 = 0.001 * ind; k3 = 0.42 * k4
print('最大生產量:', mz)
print('各年齡組魚群數:', X[ind])
print('k4=',k4); print('k3=',k3)
plt.rc('font', family='SimHei')
plt.rc('axes', unicode_minus=False)
plt.plot(np.arange(0, 1.0, 0.001), Z)
plt.ylabel('$z$', rotation=0)
plt.xlabel('$k$'); plt.show()
![](https://img2024.cnblogs.com/blog/3513989/202411/3513989-20241121225915925-1423836367.png)
![](https://img2024.cnblogs.com/blog/3513989/202411/3513989-20241121225928966-1362528167.png)