c# - Finding permutations in a parallel way -


how can write program finds permutations of sequence in parallel way??

to more exact, i'm writing program find possible schedules courses student wants take.

say student wants take cc101, , cc102.

there 3 teachers teaching cc101 (cc101.a, cc101.b, ...) , 2 teach cc102.

the combinations be

[cc101.a, cc102.a] [cc101.a, cc102.b] [cc101.b, cc102.a] [...] [cc101.c, cc102.b] 

(of course, dismissing classes collide/happen @ same time).

the way i'm handling recursive function looks this:

private list<schedule> schedules {get; set;} public findschedules(course[] courses) {    findschedules(new sched(), courses, 0);    return this.schedules; }  private void findschedules(schedule sched, course[] courses, int courseindex) {    if(i>= courses.length)    {       //class property       this.schedules.add(sched.clone());    }    foreach(var class in courses[courseindex].classes)    {       if(sched.conflictswith(class) continue;       sched.add(class);      findschedules(sched, courses, courseindex +1)      sched.remove(class);    }    } 

this works pretty well, larger number of courses large number of classes, can start build up. (# of possible combinations courses[0].classes.count * courses[1].classes.count * ...* courses[n].classes.count)

what wondering if there way make work in parallel. thinking maybe task.run(()=>findschedules(sched.clone(), courses, courseindex +1));, wouldn't want make of calls that, first few of them, , child calls regular recursive calls.

is there existing algorithm strategy this?

thanks!

here references few papers proposing parallel algorithms permutations.

parallel generation of permutations inversion vectors

an optimal parallel algorithm generating permutations in minimal change order

parallel generation of permutations , combinations

parallel generation of permutations


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -