VBA routine to allocate (randomly) given restrictions....

MagicHansen

New Member
Joined
Nov 11, 2015
Messages
2
I have a problem, and I think I best can solve it with a VBA code. So I really hope for some good ideas….....I try to explain

Basically i try to allocate persons to courses (groups) given a set of restrictions. The following just to give an example and explain the variables:

Persons16 persons – named A to P
TeamEach person is a member of a Team of 4 – Alfa, Beta, Delta, Gamma
PeriodsThere are 8 periods - 2015 to 2022
CoursesThere are 8 courses - 1 to 8
AreaCourses are subgrouped in areas (Corses 1, 2 and 3 as Area 1 etc.)

<tbody>
</tbody>

In reality the number of Persons and Teams may vary a lot. Periods and Courses will be more or less constant.

Restrictions (or conditions):

  • each person attend one course per year
  • each person must attend all 8 courses over the 8 periods
  • each course is followed by 2 persons, ie 8 courses with each 2 persons per period
  • persons from same team should not attend same course (or even better a counter/rule counts the number of case – and I can set a rule to iterate a new solution if the number is too high)
  • persons across teams should be mixed as much as possible (or like above – a counter/rule and iterate if there are too many)
  • a person should not attend courses in the same Area in successive years (the is nice to have, not need to)

It could be illustrated like this – each person gets a number 1 to 8 (in the rows), and each period (column) contains number 1 to 8 (2 of each)

https://dl.dropboxusercontent.com/u/12042084/Class.jpg


My thought is

  1. first to allocate (more or less) randomly to the courses – but somehow aided so it doesn’t have to do loops over and over until the numbers fit (does this make sense??)
  2. then define rules to check for the mixing of persons - and perhaps also teammembers in same course (if this can’t be handled in step 1)
  3. depending on the rules in 2) it could accept the solution or reiterate (back to step 1)

Im so so VBA skilled, and the only way I can resolve step 1 is endless looping (I think), but im afraid that would affect handling time??

So any suggestions, please?? ;)

Best regards
Michael
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,216,084
Messages
6,128,724
Members
449,465
Latest member
TAKLAM

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