algorithm - 0/1 用于优化的背包算法
问题描述
我的变量是;
customer = (1,2,3,4,5,6,7,8,9,10)
cost of the promotion = (10,20,30)
availability of the promotions = (2,3,5)
profit = positive integers around 100
the capacity of the knapsack = total budget
我想通过为每位客户分配 3 个促销活动之一来最大化利润。背包的容量就是总预算。我也有一些限制。
- 该算法应仅将一项促销分配给一位客户。
- 该算法应分配所有可用的促销活动。
我是这样做的。
我列出了所有组合的列表,如下所示并继续。
items = ((1,1,50),(1,2,78),(1,3,69),(2,1,45),(2,2,98),(2,3,47),(3,1,90),(3,2,36),(3,3,54),(4,1,35)...)
在哪里:
items = (i,j,k) :
i = customer
j = the promotion
k = profit
但是“项目”列表中存在依赖元素。(属于同一客户) 背包算法将元素视为独立的,因此无法正常工作。它将两个或多个促销活动分配给一个客户。
感谢是否有人可以帮助我。
谢谢
解决方案
推荐阅读
- firefox - 在 FireFox uBlock Origin 中,如何在正斜杠后阻止任何内容?
- android-ndk - 如何使用android ndk 用介子编译glib 2.66?
- r - 使用 ggplot 创建折线图
- reactjs - 减少 Jhipster React 和 spring boot 构建时间
- javascript - 如何在组件内以角度创建模块?
- python - python - 当值是系列或数据框时,应用(lambda x:...)函数应用于字典值
- apache-kafka - 我们不能在 Kafka 中加入两个表并获取数据吗?
- html - 这即使将 html、body 和 div 设置为 height=100%,高度也不会填满整个页面
- sql-server - 使用宏的 Excel (MAC) 到 SQL Server 连接
- python - 当元组中每个位置的值来自不同的列表时,从元组序列中创建值的索引数组