简体   繁体   中英

Existing algorithms for this packing/matching variant?

I have 2 arrays, one representing items and the other the bins the items can be placed in:
Ex:

ArrayItemSizes = [ 1 2 3 4 ];
ArrayBinSizes = [ 3 3 4 ];

Some rules:

  1. ArrayBinSizes and ArrayItemSizes are guaranteed to sum to the same number.( in this example they both sum to 10 )
  2. Each item can be broken into smaller pieces if needed
  3. Each item is limited to just 1 of the item being placed in the bins( so half of item 1 can be placed in a bin, half of item 1 can be placed in a different bin, but that's it for item 1 )
  4. Each item must be fully placed in the bins.

The tricky part is that I want it to have the minimum number of unique item - bin pairings.
So if ArrayItemSizes( 1 ) was split into the 3 different bins, that would result in 3 item -> bin pairings:

  1. item 1 - bin 1
  2. item 1 - bin 2
  3. item 1 - bin 3

That would be less desirable than fitting item 1 into just 1 bin, which would only create 1 item - bin pair.

A good solution would look like this:

ArrayItemSizes( 1 ) in ArrayBinSizes ( 1 )  
ArrayItemSizes( 2 ) in ArrayBinSizes ( 1 )  
ArrayItemSizes( 3 ) in ArrayBinSizes ( 2 )  
ArrayItemSizes( 4 ) in ArrayBinSizes ( 3 ) 

It has the minimum number of possible item - bin pairings( 4 pairs ), and uses all the items.

An undesirable solution would look like:

A fraction of ArrayItemSizes( 1 ) in ArrayBinSizes ( 1 )  
A fraction of ArrayItemSizes( 1 ) in ArrayBinSizes ( 2 )  
A fraction of ArrayItemSizes( 1 ) in ArrayBinSizes ( 3 )  
A fraction of ArrayItemSizes( 2 ) in ArrayBinSizes ( 1 )  
A fraction of ArrayItemSizes( 2 ) in ArrayBinSizes ( 2 )  
A fraction of ArrayItemSizes( 2 ) in ArrayBinSizes ( 3 )  

and so on...

This creates more item - bin pairings than necessary and is undesirable( 6 just for the first 2 items ). Splitting items into different bins is generally undesirable due to increasing the pair count, although often necessary to pack everything.

I'm having trouble figuring out how to represent this problem. I looked into graph pair matching stuff and knapsack/packing problems and none of them quite match.

What's a good approach for solving this? Should I be looking into optimization problem solvers, dynamic programming, graph algorithms or something else altogether?

您可以尝试用于机器托管的共享感知算法: http : //research.google.com/pubs/pub37147.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM