On the other hand, it is amenable to one of Red Woolsey's Q&D machine-tool scheduling algorithms, "Sort and Pick".

Sort the array and select consecutive entries until you reach the point where adding the next entry takes you over your magic number. If your sort is in ascending sequence, this gives you the most number of elements that will fit your constraint (this is the Maximize Number of Jobs Processed solution). If your sort is in descending sequence then you get the "Biggest Jobs Complete First" solution. Both solutions are local min/max solutions, and are reasonably easy to implement. Red claims that 95% of the time the effort involved in a full solution (by brute-force, since the problem is not algorithmically 'easy') is not cost-effective; i.e. the amount of improvement you get does not pay for the computing resources you consumed to get the better solution.

----
I Go Back to Sleep, Now.

OGB


In reply to Re: Finding the best option... by Old_Gray_Bear
in thread Finding the best option... by ruoso

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.