- 2024-10-155.4
importnumpyasnpimportmathfromscipy.optimizeimportminimize,Boundsdeffunc(x):returnsum(math.sqrt(x[i])foriinrange(100))defcon(x):return1000-np.sum(x[i]*(101-i+1)foriinrange(100))con1={'type':'ineq',
- 2024-10-14数学建模习题5.5
importnumpyasnpfromscipy.optimizeimportminimizedefobjective(x):return2x[0]+3x[0]2+3*x[1]+x[1]2+x[2]defconstraint1(x):return10-(x[0]+2x[0]**2+x[1]+2x[1]**2+x[2])defconstraint2(x):return50-(x[0]+x[0]2+x[1]+x[1]2
- 2024-10-135.5
importnumpyasnpfromscipy.optimizeimportminimizedefobjective(x):return-(2*x[0]+3*x[0]2+3*x[1]+x[1]2+x[2])defcon1(x):return10-(x[0]+2*x[0]2+x[1]+2*x[1]2+x[2])defcon2(x):return50-(x[0]+x[0]2+x[1]+x[1]2
- 2024-10-095.4
importnumpyasnpfromscipy.optimizeimportminimizedefobjective(x):return-np.sum(np.sqrt(x)*np.arange(1,101))defconstraint1(x):returnx[1]-10defconstraint2(x):return20-(x[1]+2x[2])defconstraint3(x):return30-(x[1]+2x[2]+3x[
- 2024-10-095.4 5.5
5.4求解下列非线性规划:点击查看代码importnumpyasnpfromscipy.optimizeimportminimizedefobjective(x):return-np.sum(np.sqrt(x)*np.arange(1,101))defconstraint1(x):returnx[1]-10defconstraint2(x):return20