branch-and-bound

Searching for the best fit price for multiple customers [duplicate]

廉价感情. 提交于 2019-12-13 11:25:06
问题 This question already has an answer here : Comparing multiple price options for many customers algorithmically (1 answer) Closed 5 years ago . A restatement of Comparing multiple price options for many customers algorithmically without nearly as much cruft. We have 1,000,000 customers. The cost of goods sold for each of them can be expressed as price A or price B. Price A << Price B. Price A and Price B are not linear to each other. In some cases B is 2 times as expensive, in some it is 100

Packing items into fixed number of bins

社会主义新天地 提交于 2019-12-12 11:05:01
问题 I am looking for an algorithm that will solve my problem in the most efficient way. Problem description: I have a list of items (only positive integers are allowed) and fixed number of bins of identical capacity. So far, I thought about branch-and-bound algorithm, but I am not quite sure if it is the best approach in this case. Example: Given a list of items: (3, 4, 4, 2, 3, 9, 2) and three bins of capacity 9 each I need to pack them this: (order of items is irrelevant) [3, 4, 2], [4, 3, 2],

Comparing multiple price options for many customers algorithmically

不问归期 提交于 2019-12-04 05:14:04
问题 We have 1,000,000 customers. The cost of goods sold for each of them can be expressed as price A or price B. Price A << Price B. Price A and Price B are not linear to each other. In some cases B is 2 times as expensive, in some it is 100 times. cost of all the customers on A is min( (sum(A)/count(A)) , 100 ) * count(A) Effectively, the average cost of all the customers on A will be rounded up to 100 if it is less than 100. There is no such restriction on B. I would like to spend the least

Implementing branch and bound for knapsack

て烟熏妆下的殇ゞ 提交于 2019-11-29 22:14:58
问题 I'm having a headache implementing this (awful) pseudo-java code (I wonder: why the hell people do that?) for the b&b knapsack problem. This is my implementation so far, which outputs a maximum of 80 (when it should print 90, for the items on the textbook sample). I created a Comparator (on a LinkedList) to sort the elements by Pi/Wi before passing them to the algorithm, but on this input is already presorted. I'm debugging right now (and updating the posted code), cause I guess it's an array

TSP - Branch and bound

夙愿已清 提交于 2019-11-28 01:07:49
I'm trying to solve the TSP with Branch and bound algorithm. I must build a matrix with costs but I have this problem: I have city with coordinates x and y. The cost of traveling is ceil(ceil(sqrt((x1-x2)^2+(y1-y2)^2))/v) + days spent in the city. V is speed. Days spent in the city depends from day when w comes to the city. For example if we arrived on Monday(t1) to city 1, we stay for 9 days but if we arrived on Tuesday, then we stay in the city for 4 days. x y t1 . t7 city 1. 79 -36 9 4 8 5 5 7 8 city 2. 8 67 6 9 2 1 9 9 1 city 3. 29 57 7 5 10 8 10 9 4 How can I solve this problem using

TSP - Branch and bound

守給你的承諾、 提交于 2019-11-26 23:28:52
问题 I'm trying to solve the TSP with Branch and bound algorithm. I must build a matrix with costs but I have this problem: I have city with coordinates x and y. The cost of traveling is ceil(ceil(sqrt((x1-x2)^2+(y1-y2)^2))/v) + days spent in the city. V is speed. Days spent in the city depends from day when w comes to the city. For example if we arrived on Monday(t1) to city 1, we stay for 9 days but if we arrived on Tuesday, then we stay in the city for 4 days. x y t1 . t7 city 1. 79 -36 9 4 8 5