What's it called when I want to choose items to fill container as full as possible - and what algorithm should I use?

前端 未结 2 654
情书的邮戳
情书的邮戳 2021-01-05 18:07

I have a problem as follows:

You are given item types of weight w1, w2, w3, .... wn; each item of these types is infinite in quantity.

You have a

2条回答
  •  醉酒成梦
    2021-01-05 18:38

    If I have understood the problem correctly,

    For xi belongs to {0,1, ... infinity} (i = 1 to n)
    Maximize summation(wixi) (i = 1 to n)
    subject to:
    summation (wixi) <= W
    

    You can solve it using an Integer Linear Programming Solver.

    EDIT: as pointed out by Preston Guillot, it is a special case of knapsack problem where the value and mass of the items are the same.

提交回复
热议问题