如何将条件成本应用于Python纸浆中的目标功能?

发布于 2025-02-13 17:26:06 字数 218 浏览 0 评论 0原文

我正在优化到不同银行的交易流量,例如A和B之间。每次交易的成本是固定的,但是该费用取决于总数(例如银行A:1美元,如果在0-10亿美元之间,则为0.9美元,如果1000万美元+,并且银行b)。

我有需要进行的交易数量的预测,因此我的决策变量是到每个银行的交易数量。但是我正在努力制定目标函数以使用正确的成本,因为它们取决于决策变量的值。

我是纸浆和优化的新手,因此努力了解如何实施这种目标功能。

I'm optimising transaction traffic to different banks, say between A and B. The cost of each transaction is fixed, but that fee is dependent on overall volume (e.g. Bank A: $1 if between 0-10m transactions, $0.9 if 10m+, and something different for Bank B).

I have a forecast of number of transactions I'll need to make, so my decision variables are number of transactions to each bank. But I'm struggling to formulate objective function to use the right costs as they depend on the values of the decision variables.

I'm new to PuLP and optimisation so struggling to understand how to implement such objective function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混吃等死 2025-02-20 17:26:06

通常将其建模为分段线性函数。对于初学者来说,这可能有些吓人,但是有一些公式。他们通常使用二进制变量(或类似),因此更困难。

配方集合在这里: https://yetanothermathprogrammingconsultant.blogspot.com/2019/02/piecewise-linear-functions-and-html 。您可能需要首先关注方法2,因为这是使用二进制变量。 SOS1/SOS2变量仅在更高端求解器中可用。抱歉,这并不像您预期​​的那样简单。

在某些情况下,这些分段线性函数不需要二进制变量。例如,当事情保持凸。如果较大的数量总是比较小的量(与折扣相反),则可能是这种情况。另一个问题是,这些折扣的精确配方取决于细节,例如,折扣适用于一切或仅适用于1000万美元的零件。折扣方案在实践中可能变得非常复杂。

That is often modeled as a piecewise linear function. This can be a bit intimidating for a beginner, but there are formulations for this. They typically use binary variables (or similar), so it is more difficult.

A collection of formulations is here: https://yetanothermathprogrammingconsultant.blogspot.com/2019/02/piecewise-linear-functions-and.html. You may want to focus first on method 2 as that is using binary variables. SOS1/SOS2 variables are only available in more high-end solvers. Sorry, this is not as simple as you may have expected.

In some cases, these piecewise linear functions don't need binary variables. E.g. when things stay convex. This can be the case if larger amounts are always more expensive than smaller amounts (the opposite of a discount). Another issue is that the precise formulation of these discounts depends on the details, like if the discount is for everything or only for the part greater than $10m. Discount schemes can become quite complicated in practice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文