+ Reply to Thread
Results 1 to 6 of 6

Most Sets Achievable

  1. #1
    Registered User
    Join Date
    12-30-2018
    Location
    Qatar
    MS-Off Ver
    2010
    Posts
    2

    Most Sets Achievable

    Hi All,

    Please find attached excel database. I am trying to find the most number of "Sets" with a group of "Items" based on the following conditions:-

    a) Must choose 6 Items.
    b) In order for a Set to be considered eligible, the total sum of the 6 Items under a Set must equal to 4 or higher.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,422

    Re: Most Sets Achievable

    Welcome to the forum!

    I think we shall need a little more guidance regarding the sample workbook - how exactly does it relate to your request? More detail, please. What is your expected output, for instance? And where has this been mocked up in the workbook?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-30-2018
    Location
    Qatar
    MS-Off Ver
    2010
    Posts
    2

    Re: Most Sets Achievable

    Hi,

    Thanks for the swift response.

    What i am trying to achieve is to obtain the most optimum combination of Items which can provide the most Sets (with a Sum of 4 or higher).

    For instance if i were to choose Items FM, BSB, DC,BS, SSL & TD, i would be able to achieve 4 Sets (i.e. A,B,C & J). I found these combination of sets through lots of trial and error.

    I am wondering if anyone know an easier way to find the most optimum combination of Items based on the conditions.
    a) Must choose 6 Items.
    b) In order for a Set to be considered eligible, the total sum of the 6 Items under a Set must equal to 4 or higher

    I hope i am clear.

    Many thanks in advance.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Most Sets Achievable

    What's the genesis of the problem and the value in its solution?

    Why not pick all of the items and all of the sets that have four or more items?

    How do you evaluate the merit of a given solution?
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Most Sets Achievable

    In the interim, pending clarification s per shg's comment, here is a partial solution to the problem as originally stated:

    First there are a couple of duplicates in the "Item" column: BS appears twice as does FS although I don't think that impacts the problem as stated assuming these should be distinct names.

    Choosing 6 from 68 is probably too many combinations to exhaustively examine in a reasonable time, so I chose a Monte Carlo method, randomly choosing sets of 6 items and checking each combination for >= 4 Sets. This method found a number of sets of four, for example:
    FM, HP, AS, BS, PD, SF: ==> B, C, I, SF
    FM, BSB, DC, BS, HM, SS ==> C, H, J, M
    FM, BSB, DC, BS, DT, FS ==> B, C, F, J

    I ran the calculations for about 10 minutes and found no sets greater than 4.

    Here's the details of what I did:

    Column D contains 6 "y"s for the set of 6 to be tested. I set D3 to always be "y" as it has a "1" in the vast majority of columns. The worksheet is already sorted in order of the most "appearances" in a given row, so I arbitrarily chose to cut off my tests at D17 as higher rows have 3 or less "appearances. I randomly choose five columns from D4:D17 using the following in D4 copied down to D17:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The idea is to have the "y"s evenly distributed throughout the range - not sure I have that totally correct, but it seems to work well enough.

    E73:AE73 sums the 1's for the 6 selected items for each set: e73 copied across:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    D72 is set to the goal number of sets we're searching for (5 for example).
    D73 is the actual number of sets found for the current combination of 6 items.

    At this point it is possible to keep pressing F9 "recalculate" while watching cell D73. But easier on the finger, the following few lines of VBA automate the recalculation and stop the recalculations if the goal is met.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Most Sets Achievable

    Macro trueno in the attachment ratchets through all the combinations in about 25 minutes to arrive at

    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    R
    S
    T
    U
    V
    W
    X
    Y
    Z
    AA
    AB
    AC
    AD
    1
    Total
    2
    2
    4
    1
    1
    1
    1
    4
    0
    4
    0
    0
    4
    0
    0
    0
    0
    1
    0
    0
    1
    0
    0
    0
    0
    0
    0
    4
    2
    3
    Items\Sets
    Select
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    R
    S
    T
    U
    V
    W
    X
    Y
    Z
    AA
    5
    BSB
    1
    1
    1
    1
    1
    1
    6
    DC
    1
    1
    1
    1
    1
    1
    9
    BS
    1
    1
    1
    1
    1
    12
    FC
    1
    1
    1
    1
    1
    13
    HM
    1
    1
    1
    1
    1
    16
    SS
    1
    1
    1
    1
    1


    The Monte Carlo approach is not a bad alternative.
    Attached Files Attached Files
    Last edited by shg; 12-31-2018 at 01:27 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How To Compare Two Sets Of Similar Data Sets To Find a Good Match
    By Mark123456789 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2016, 01:29 AM
  2. [SOLVED] Calculating total achievable marks based on cells returning a value
    By Dabooka in forum Excel General
    Replies: 3
    Last Post: 08-15-2016, 06:59 AM
  3. [SOLVED] Getting row sets one below the other.
    By PritishD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2015, 03:19 AM
  4. Record Sets
    By Dave777 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-06-2014, 04:19 AM
  5. Add two sets of data
    By djfriedman in forum Excel General
    Replies: 4
    Last Post: 08-19-2010, 11:23 AM
  6. Two sets of data for X-axis and 2 sets of data for Y
    By lord_jagganath in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 12-07-2009, 07:44 PM
  7. Need to Insert down between sets then border sets
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-10-2008, 04:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1