[英]How to write cost slabs in objective function of Linear Programming?
假设我有一个可变的每月收入,在1到12个月的时间里,我的总收入为1700美元,我想尽量减少对该收入的纳税。 我应该如何用抽象代数形式写此目标函数Z = 1000 * 0.05 + 500 * 0.10 + 200 * 0.15
基本上,我想对总收入计税,有什么建议吗?
我有三个平板0-1000、1000-1500,> 1500个税/平板0.05、0.10、0.15
这是python中的示例实现:
def tax(x):
if (x <= 1000):
return x * 0.05
elif (x <= 1500):
return 50 + (x - 1000) * 0.1
else:
return 100 + (x - 1500) * 0.15
income = 100
while (income < 5000):
print ("Taxes on income of " + str(income) + ": " + str(tax(income)))
income += 250
您可以根据需要参数化步骤和速率。
如果需要从结果回归分段函数,可以使用numpy.piecewise
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.