Lambda or VBA to solve the pairs webinar problem!!!

Phantom1

New Member
Joined
Sep 26, 2018
Messages
24
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Let's say that we have a data table of courses and people registered to them. The original data can have 120000 of rows and around 100 different courses. Here is a simple data table for clarity.

1728738915845.png

Thanks to djclements I constructed a table that shows conflicts for each pair of courses.
(Also special thanks to all other people for providing advice and solution to that problem. Fluff, hagia_sofia, Peter_SSs, Domenic and JEC. See post "Lambda to count pairs and output array based on criteria")
1728739055265.png


And here is the problem: We now want to organize webinars for courses of level A.
As a start, each course could be on a different day so 7 days will be required. This is not essential though.

By noticing the zeros in the table, it is clear that course c2 can be at the same day with c3 or c5 or c6 or c7 but not with all of them because there is conflict, for example between c3 and c5.
But course c2 can be grouped with c3 and c7 because there isn't a conflict for all combinations of two of these.
So we can schedule 4 groups that will need four different times or days to create a program. The order of days does not matter.
1st day: c1
2nd day: c2,c3,c7
3rd day: c5
4th day: c6

As we can see now only four days are required for the webinars.

For purposes of a better distribution we observe that c7 has no conflicts with c5 and can be grouped with that. So we have 2 lessons in each of 2nd and 3rd day instead of 3 and 1 respectively.
So another solution and more preferable would be
1st day: c1
2nd day: c2,c3
3rd day: c5,c7
4th day: c6

As I can see it can not be done in less days, but different combinations can be solutions. For example
1st day: c1
2nd day: c2,c5
3rd day: c3,c7
4th day: c6

If we only have n days available we need to minimize the number of conflicts but with the restriction that no one can have more than two webinars in the same day.
For example if n =3 is stated we can have for example
1st day: c1,c6
2nd day: c2,c3
3rd day: c5,c7
No of conflicts c1,c6 :2
or
1st day: c1,c3
2nd day: c2,c5,c7
3rd day: c6
No of conflicts c1,c3 :1 which is a better choice.

If n is stated as a number greater than 4, the grouping with the 4 days with no conflicts is what we want.

Task 1(mandatory):
Given the table of conflicts and number for available days n, create grouping of courses in n days with the least number of conflicts and a grouping of no conflicts with the least number of days required.
If with the specified n, a person must have more than two webinars in same day report "More days are needed."
Task 2(optional 1):
Try the number of courses of each group to be as close to each other as possible for better distribution.
Task 3(optional 2):
As this is a graph coloring problem, a tree would be a nice addon.
No colors needed though, as this might be too difficult.
1728739517351.png

Any solution with VBA or lambda functions will be highly appreciated.
Honestly, i didn't come even close to solve it.😏

Many thanks in advance
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,223,929
Messages
6,175,461
Members
452,645
Latest member
Tante

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top