Best fit algorithm for bundling/grouping

Options

I have a group of different products having different quantities and want to bundle them in to groups summing up to 10 as close as possible. For example, below I have 11 products and I want to break them in to groups that would have the sum of the quantity equal to or closest to 10. Has anyone tried something like this in Anaplan?

Product

Quantity

Product 1:

2.15

Product 2:

1.5

Product 3:

3.2

Product 4:

2

Product 5:

0.4

Product 6:

3

Product 7:

1.8

Product 8:

2.35

Product 9:

2.75

Product 10:

0.75

Product 11:

0.1

So an output for the above are 2 groups with the following groupings:

Group 1:

Product 2:

1.5

Product 4:

2

Product 6:

3

Product 9:

2.75

Product 10:

0.75

Total Group 1:

10

Group 2:

Product 3:

3.2

Product 7:

1.8

Product 8:

2.35

Product 1:

2.15

Product 5:

0.4

Product 11:

0.1

Total Group 2:

10

Answers

  • Dikshant
    Options

    Hey, that looks interesting. Do you want to create groups automatically where the sum of products is 10?

  • PujithaB
    edited March 18
    Options

    Hi @TristanS
    Insightful Question
    We can think this mathematically as below.
    Step1: Try to add previous list value to current value and then comapre Sum of it with next time addition of previous list value to current value

    Lineitem1 : add previous list value to current value
    Lineitem2 : if Lineitem1 Close to 10 and Next of Lineitem1 >10 then mark those product name
    Lineitem 3: In this lineitem try to name each group with group1,group2 ……

    It will create groups as below, but not as you have mentioned on the top

    Product

    Quantity

    Product 1:

    2.15

    Group 1

    Product 2:

    1.5

    Group 1

    Product 3:

    3.2

    Group 1

    Product 4:

    2

    Group 1

    Product 5:

    0.4

    Group 1

    Product 6:

    3

    Group2

    Product 7:

    1.8

    Group2

    Product 8:

    2.35

    Group2

    Product 9:

    2.75

    Group2

    Product 10:

    0.75

    Group2

    Product 11:

    0.1

    Group2

    Looking forward to see if this can be solved in any other way

  • Dikshant
    Options

    Pujitha - a challenge here - With this way, starting all products when quantity < 10 will be grouped. But the bigger challenge might be to find all possible groups automatically.

    That's what i am looking to clarify with Tristan and confirm.

  • TristanS
    Options

    @Dikshant Yes I want to automatically create groups where sum of products is 10

  • Dikshant
    Options

    All possible combinations of groups, right? Or is there a limit to how many groups you need?

  • TristanS
    Options

    @Dikshant No limit on number of groups. Rules are:

    • A product must belong to a group and one group only
    • The grouping should sum up to 10 or closest to 10

    FYI: This is for optimising cargo load. E.g. a transport has a maximum capacity of 10 units so you want to fill up the transport to the maximum possible given amount of products requiring delivery.

    I'm across recursive algorithms outside Anaplan but not quite sure Anaplan would be able to do it even though Anaplan supports some form of recursion via time dimension through previous and next function calls.

  • Olek P
    Options

    @TristanS

    At my finance company we do something similar. We have a bunch of contracts that we must put into different funding vehicles. Each vehicle has a lot of different constraints such as 25% of contracts can't be in Florida or no more than 10% of contracts can be longer than 12 months. We use anaplan for this. I will have to get back to you on specifics. We can't possibly run all the possibilities (we have 1,000s of contracts everyday). So what we do is we have the model spit out 3 different scenarios and we pick the one we like best. Hope that helps

  • TristanS
    Options

    @Olek P Sounds like an option worth considering for us to implement.