+ Reply to Thread
Results 1 to 2 of 2

VBA macro to allocate persons to courses over periods - with restrictions...

  1. #1
    Registered User
    Join Date
    11-13-2015
    Location
    Hjemme, Denmark
    MS-Off Ver
    2010
    Posts
    1

    VBA macro to allocate persons to courses over periods - with restrictions...

    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:

    Persons 16 persons – named A to P
    Team Each person is a member of a Team of 4 – Alfa, Beta, Delta, Gamma
    Periods There are 8 periods - 2015 to 2022
    Courses There are 8 courses - 1 to 8
    Area Courses are subgrouped in areas (Corses 1, 2 and 3 as Area 1 etc.)

    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.png


    My thought is

    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??)
    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)
    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
    Attached Images Attached Images

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA macro to allocate persons to courses over periods - with restrictions...

    One way to do this is to create a scoring function which gives you a number where a positive weight is given to the things that you want and a negative to those that don't. Make an initial random assignment and calculate the function. Then swap two people at random and recalculate. If the score improves then keep the change and swap another two at random and repeat. If the score is worse then revert before trying another swap.

    It's worth keeping a count of the number of swaps since the last improvement so that you can set a threshold at which to stop.
    Martin

+ 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. [SOLVED] Macro to Transpose data for various Courses attended by each employee
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-27-2015, 06:46 PM
  2. [SOLVED] How to allocate $0.00 equally across different Periods (Q1, Q2, Q3, Q4).
    By Calejobe in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-19-2015, 02:31 PM
  3. [SOLVED] Allocate Offers to Persons
    By Henni in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-18-2013, 09:34 AM
  4. [SOLVED] Allocate months across periods in which they fall?
    By maladrat in forum Excel General
    Replies: 9
    Last Post: 07-26-2012, 01:21 PM
  5. online macro courses
    By alanyaber in forum Excel General
    Replies: 2
    Last Post: 11-14-2009, 04:02 AM
  6. Allocate days into periods in which they fall
    By BRISBANEBOB in forum Excel General
    Replies: 2
    Last Post: 07-05-2009, 07:31 PM
  7. Replies: 0
    Last Post: 04-03-2006, 04:02 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