Hello Monks!

This isn't so much a perl specific question, but rather an interesting programming/logic question and I fear that my brain has broken, and I need some help!

Essentially I have 11 'events', each lasting exactly 1 second, that need to reoccur at various time intervals (rather, max time between intervals), having only a single event occur at once. The tricky part is that I need to figure out if there is a 12th event I can squeeze in periodically without breaking the max time interval rules for the other 11.

The rules are, every:
a = 4 seconds
b = 4 seconds
c = 4 seconds
d = 24 seconds
e = 24 seconds
f = 24 seconds
g = 100 seconds
h = 150 seconds
i = 150 seconds
j = 150 seconds
k = 600 seconds

A valid start would be "a, b, c, d, a, b, c, e, a, b, c, f, a, b, c, g, a, b, c, h, a, b, c, d..." etc, though 'd' was forced to be refreshed on the 21st second because of upcoming 'a' 'b' and 'c's.

I'm having a problem thinking through the best way to map these time allotments. My initial thought was to count through time and see which event was most overdue and slide that in next, but then you could potentially run into a scenario where multiple come due without enough time for them to all occur without breaking a rule. My next thought is for each time step, to count forward through the next 600 mapping everything out.

I need help thinking through how to predictively optimize the order so that no rule is EVER broken, and in the process of doing that, see how many of the 12th event type can be inserted an average every, say, hour or so. The first half hour is easy to think through, but the 10th hour? The 30th? I can't do it by hand. My first attempt was copy and pasting for an entire 11x600 grid of cells in excel, but there has to be a more optimized way... right?

If my math is right, there should be 56 available slots to squeeze 'L' messages in, in a given hour, if the system is perfectly optimized (which I don't think is possible). How can I find what the real number is, once the system is steady state, to +-5?

In reply to Time Allotments by alanonymous

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.