DpythonProject3会员信息附件二:会员信息数据xlsx其中文件中‘商品GPS纬度’和‘商品GPS经度’两列的数据组成商品的位置信息‘会员GPS纬度’和‘会员GPS经度’两列数据组成会员的位置信息文件中‘预订任务限额’是每个会员对应的任务限额文件中‘任务标价’那列的数据代表商品的价格设定‘q2’为任务限额设定商品关于会员的距离为‘r’设定引力子为‘y’设定一个常量为‘k’和一个常量‘n’
import pandas as pd
Read the Excel file
df = pd.read_excel(r'D:\pythonProject3\会员信息\附件二:会员信息数据.xlsx')
Calculate the distance between the member and the product
df['Distance'] = ((df['商品GPS纬度'] - df['会员GPS纬度'])**2 + (df['商品GPS经度'] - df['会员GPS经度'])**2)**0.5
Find the minimum value of the product price
q1 = df['任务标价'].min()
Find the minimum value of the gravitational force
min_gravity = float('inf') for n in range(1, 10): for m in range(1, 10): for k in range(1, 10): gravity = k * q1 * (df['预订任务限额']**m) / (df['Distance']**n) if gravity.sum() < min_gravity: min_gravity = gravity.sum() best_n = n best_m = m best_k = k
Output the formula with constants
formula = f'y = {best_k}q1({df["预订任务限额"]}^{best_m})/({df["Distance"]}^{best_n})' print(formula)
原文地址: https://www.cveoy.top/t/topic/ixJ9 著作权归作者所有。请勿转载和采集!