+ Reply to Thread
Results 1 to 3 of 3

Optimize and pairing

  1. #1
    Registered User
    Join Date
    04-09-2020
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    2

    Optimize and pairing

    Hi,

    I have a bunch of subjects that I need to pair them up in a group of 2, but some subjects cannot be paired with some of them, the relationships between them is attached: The cells "FAIL" means that they cannot be paired together, e.g.: No6 and No3 cannot be paired together.

    The subjects cannot be repeated in multiple pairs, i.e. if No7 is paired with No9, No7 cannot be paired with No1, No2, etc...

    Are there any ways to optimize the pairing with the maximum number of pairs as an outcome?

    Thank you so much!

    Dexter
    Attached Files Attached Files
    Last edited by chengdexter724; 04-14-2020 at 11:29 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: Optimize and pairing

    The Solver tool (a standard add-in installed with Excel, but not activated) could be used for that.
    If you are not familiar and don't have it installed (check far right part of Data Ribbon) start with: https://support.office.com/en-us/art...c-e24772f078ca

    See how I did it in attached file.

    I used A13:B17 as variables for the solver model.
    Wrote there numbers from 1 to 10.
    In solver I added condition, that the values in this range have to be all unique
    Then in column C added checking if the pair in columns A and B is allowed (C13 and copy down):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In C18 I added formula checking how many allowed pairs were selected:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and set this cell as an aim for the solver (maximizing the value of C18).
    Then I selected Solving method as Evolutionary (as the problem is of discrete nature) and run Solver

    The conditions were not very tight (there are many allowed pairs), so very quickly Solver ended up with 5 pairs solution.

    We could end up here as the task is done, but I added some bells and whistles like conditional formatting to show which pairs were selected in the original matrix. Selected B2:K11 and used conditional formatting with rule based on formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    formula in D13 copied down and right:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And another conditional formatting - for range: D13:E17 based on formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Write some starting numbers (like below) in A13:B17 and use Solver yourself. The solution will be probably different, but shall not be worse :-)
    1 2
    3 4
    5 6
    7 8
    9 10
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    04-09-2020
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    2

    Re: Optimize and pairing

    Thank you for the help! That is exactly what I needed!

+ 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. Pairing workdesks
    By NiCeXoTiC in forum Excel General
    Replies: 1
    Last Post: 01-28-2020, 06:04 AM
  2. Pairing data with itself?
    By amolo in forum Excel General
    Replies: 1
    Last Post: 07-13-2016, 04:17 PM
  3. [SOLVED] Pairing people according to strengths
    By Petrus81 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-20-2015, 08:11 AM
  4. Pairing/Grouping People
    By gslgroup in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-30-2014, 02:58 PM
  5. help pairing columns
    By YORKS12345 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-11-2014, 01:16 AM
  6. Data Pairing
    By frankymute in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 01-23-2014, 01:00 AM
  7. Random pairing
    By woodnwine in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2010, 01:01 AM

Tags for this Thread

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