Multiple Constraint Knapsack Problem

后端 未结 5 1805
花落未央
花落未央 2020-12-08 05:29

If there is more than one constraint (for example, both a volume limit and a weight limit, where the volume and weight of each item are not related), we get the multiply-con

5条回答
  •  一生所求
    2020-12-08 06:00

    Merge the constraints. Look at http://www.diku.dk/~pisinger/95-1.pdf chapter 1.3.1 called Merging the Constraints.

    An example is say you have
    variable , constraint1 , constraint2
    1 , 43 , 66
    2 , 65 , 54
    3 , 34 , 49
    4 , 99 , 32
    5 , 2 , 88

    Multiply the first constraint by some big number then add it to the second constraint.

    So you have
    variable , merged constraint
    1 , 430066
    2 , 650054
    3 , 340049
    4 , 990032
    5 , 20088

    From there do whatever algorithm you wanted to do with one constraint. The main limiter that comes to mind with this how many digits your variable can hold.

提交回复
热议问题