首页 > 解决方案 > 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  

但是“项目”列表中存在依赖元素。(属于同一客户) 背包算法将元素视为独立的,因此无法正常工作。它将两个或多个促销活动分配给一个客户。

感谢是否有人可以帮助我。
谢谢

标签: algorithmoptimizationknapsack-problem

解决方案


推荐阅读