简体   繁体   English

PuLP 目标函数未在 lpSum 中包含常数

[英]PuLP objective function not incorporating constant in lpSum

Any idea why the following objective function doesn't include the -5000 in its formulation?知道为什么以下目标函数在其公式中不包含 -5000 吗?

prob += lp.lpSum([-5000 + price_today_d[i] * ticker_vars[i] for i in ticker_list]), 'Total Cost'

Result:结果:

Total_Cost: 0.82 ticker_A + 27.55 ticker_B
 + 32.73 ticker_C + 30.14 ticker_D + 26.55 ticker_E

By default PuLP ignores constant values since they are not relevant for obtaining the optimal solution.默认情况下,PuLP 会忽略常量值,因为它们与获得最佳解决方案无关。 You can always add it after solving.您可以在解决后随时添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM