from scipy.optimize import minimize import math import numpy as np def fun(x): return x[0] * math.sqrt((x[1] - 1.25) ** 2 + (x[2] - 1.25) ** 2) + x[3] * math.sqrt((x[14] - 1.25) ** 2 + (x[15] - 1.25) ** 2) + x[4] * math.sqrt((x[1] - 8.75) ** 2 + (x[2] - 0.75) ** 2) + x[5] * math.sqrt((x[14] - 8.75) ** 2 + (x[15] - 0.75) ** 2) + x[6] * math.sqrt((x[1] - 0.5) ** 2 + (x[2] - 4.75) ** 2) + x[7] * math.sqrt((x[14] - 0.5) ** 2 + (x[15] - 4.75) ** 2) + x[8] * math.sqrt((x[1] - 5.75) ** 2 + (x[2] - 5) ** 2) + x[9] * math.sqrt((x[14] - 5.75) ** 2 + (x[15] - 5) ** 2) + x[10] * math.sqrt((x[1] - 3) ** 2 + (x[2] - 6.5) ** 2) + x[11] * math.sqrt((x[14] - 3) ** 2 + (x[15] - 6.5) ** 2) + x[12] * math.sqrt((x[1] - 7.25) ** 2 + (x[2] - 7.25) ** 2) + x[13] * math.sqrt((x[14] - 7.25) ** 2 + (x[15] - 7.25) ** 2) cons1 = {'type': 'ineq', 'fun': lambda x: x[0] + x[3] - 3} cons
1.4的笔记
最新推荐文章于 2024-07-19 16:36:18 发布