• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

C# Distributing jobs fairly on accounts - distribution algorithm

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on a project that publish to a multiple websites using a multiple accounts. each account can publish to a specific website. as shown in the 'Dict' below. The problem is I'm trying to distribute the publishing jobs on accounts fairly and making a distance between accounts that has more than 1 job.

So, Let's say that we have the following accounts list:



and the following sites list:



Each account can publish to a specific site according to the following dynamic dictionary:

Key: Is the 'site ID' and value is a list of accounts IDs that can publish to that site.




Publishing jobs are created as follows:




when the jobs are created it is something similar to (Before re-adjusting the jobs distribution)



> Account-A Publish on Site-A
> Account-E Publish on Site-B
> Account-D Publish on Site-C
> Account-A Publish on Site-D
> Account-A Publish on Site-E



The publishing jobs created above are not fairly distributed to accounts, as you can see 'Account-A' has 3 jobs assigned while there's an other accounts can publish to the 'sites' as defined in 'Dict' so it should look something like:


> Account-C Publish on Site-A
> Account-E Publish on Site-B
> Account-A Publish on Site-D
> Account-D Publish on Site-C
> Account-A Publish on Site-E



In the output above the jobs are distributed fairly on accounts and also there's a distance between accounts that has more than 1 job

An example on distance between jobs


   > Account-A Publish on Site-A
   > Account-E Publish on Site-B
   > Account-D Publish on Site-C
   > Account-A Publish on Site-D
   > Account-A Publish on Site-E


Job 4 and 5 are being processed by Account-A. An account should not process two jobs sequentially, so it could be swapped with another job, something like this


   > Account-A Publish on Site-A
   > Account-E Publish on Site-B
   > Account-A Publish on Site-D
   > Account-D Publish on Site-C
   > Account-A Publish on Site-E



It will be highly appreciated if you could help. I need an algorithm that do the job distribution to get similar output. Performance is not important.

Thank you..


 
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

khaled ahmad wrote:
Each account can publish to a specific site according to the following dynamic dictionary:

Key: Is the 'site ID' and value is a list of accounts IDs that can publish to that site.



khaled ahmad wrote:

Publishing jobs are created as follows:




The publishing jobs created above are not fairly distributed to accounts, as you can see 'Account-A' has 3 jobs assigned while there's an other accounts can publish to the 'sites' as defined in 'Dict' so it should look something like:



It's not completely clear - at least to me - what accountIdsAssoc.PickRandomAccount(); does really, but as a first glance looks like that since grants to publish on a server are not fairly distributed too,  given a site is more likely to draw Account A than the others.
Indeed A could publish on each server - with the sole exception of site C - while account E and D can also use server B and C, respectively. So i would guess to have more jobs assigned to A.
If you want to be fair with respect to the number of jobs associated with accounts, you should iterate over accounts and assign a job for each account, in a round-robin way. You could also be fair with servers workload, for example when it's Account A turn, you should pick the less loaded server where A can publish works.
For E or D accounts you have no choice.




 
Claude Moore
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the ranch !
 
Rancher
Posts: 119
8
Mac Mac OS X Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could also think of it like this...

Determine how capable each sender is. By counting the number of sites they can each send too. you want to keep all senders busy, so the senders with the lowest number of sites they can publish to, should come first. Your pickiest workers should get the first crack at any jobs. You're least picky workers will pick up any remainder.

I would recommend you rearrange your data to be like this...


Annotate-then-Execute is usually a better model than Loop-and-Calculate. Mostly because you can use the debugger to expect the system easily in this model.
 
Nothing? Or something? Like this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic