Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:35:46+00:00 2026-06-13T22:35:46+00:00

For example, you have several lists of double s, which you need to distribute

  • 0

For example, you have several lists of doubles, which you need to distribute in several “buckets” of fixed size (bucket size is also a double). There are two additional constraints:

  • Values from certain lists can go only to certain (pre-specified) buckets:

    bucket1 <-\
               |--- list1
              /
             /
    bucket2 <--\
    bucket3 <---- list2
    bucket4 <--/
    
    bucket5 <--- list3
    
  • The resulting distribution must be as uniform as possible (so that all buckets have load factor of, for example, 0.5).

Specific example of such problem: imagine if you have several power supply units (“buckets”), and several boards of lamps. Each supply unit is connected to one or several boards, each supply unit has different capacity, lamps consume different amounts of energy. If some board is connected to several supply units, then you can “assign” some of the lamps to first power supply, some – to second, etc.

Doing this with a bruteforce quickly becomes non-feasible for big number of elements.

Is there an efficient approach?

EDIT: I devised the following approach – which seems to converge on the needed result fairly quickly. The idea is as following:

  • First, for each list, I distribute items into allowed buckets, using least-loaded-bucket heuristic.
  • Then, I do the following:
    • for each list:
      • remove the items corresponding to the list from the buckets
      • distribute them again, using the same least-loaded heuristic
      • calculate the ratio of max-loaded bucket size to least-loaded (for allowed buckets)
    • terminate the loop if ratio is less than some constant (I took 1.02), or if too many steps passed.

The general idea is to “smooth” the buckets until the distribution becomes flat enough, which usually means that we reached the needed target.

Is it a good algorithm?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:35:47+00:00Added an answer on June 13, 2026 at 10:35 pm

    Sounds to me like a bin packing problem or knapsack problem with additional constraints (certain lists can only go to specific buckets) for which you want a solution that fills all buckets to at least a specific load factor. Speaking of “efficient”, I would say that what you describe should be NP-hard (“should” because I haven’t had the time to think about a reduction from a NP-problem to your specific problem yet but I am pretty sure there is one).

    What you could try: First solve the constraint problem and determine which lines can go in which buckets and then fill the buckets greedily. If your constraints are hard you can do backtracking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There have been several questions posted to SO about floating-point representation. For example, the
I have a div <div id=masterdiv> which has several child <div> s. Example: <div
I have several lists, that you can consider as rows of integers. For example
I have several sites in different domains: example.com , example.org , mail.example.com and passport.example.org
I have several delimiters. For example {del1, del2, del3 }. Suppose I have text
I have been searching several days for an example of how to make a
I have made modifications to several example OpenCV projects within Android, however I am
I have a function that updates several tables. As an example, let's say it
I have an application with several windows/views that show the same object. For example
I have a table, for example, mytable. It has several columns: col1, col2, col3.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.