This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

C# Distributing jobs fairly on accounts - distribution algorithm  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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: 1093
36
IBM DB2 Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • 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: 1093
36
IBM DB2 Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the ranch !
 
Rancher
Posts: 37
5
Mac Mac OS X Safari
  • Mark post as helpful
  • send pies
  • 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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!