2
$\begingroup$

I receive a vector of varying length such as [0, 1, 2, 3, 2]. The value corresponds to the yield and its position to a time slot. Hence, at the first time slot the yield is zero, at the second period it is 1, etc.

I need a procedure that can combine this vector with itself at varying periods in order to ensure that the sum of the yields are the "most possibly" stable. Ideally it will be completely but I doubt that it is always possible.

I also need to make sure that it is indeed a periodic solution.

Below 2 examples that I solved by hand and a list of other example I don't know how to solve:

First one:

     [0, 1, 2, 3, 2]   [0, 1, 2, 3, 2]
           [0, 1, 2, 3, 2]   [0, 1, 2, 3, 2]
                 [0, 1, 2, 3, 2]   [0, 1, 2, 3, 2]
sum = 0  1  2  4  4  4  4  4  4  4  4  4...
In this example after an initialization period of length 3, we get a stable 
pattern with a yield of 4

Second one:

     [0, 0, 0, 1, 0, 1, 0, 1]            [0, 0, 0, 1, 0, 1, 0, 1]
        [0, 0, 0, 1, 0, 1, 0, 1]            [0, 0, 0, 1, 0, 1, 0, 1]
                       [0, 0, 0, 1, 0, 1, 0, 1]            [0, 0, 0, 1, 0, 1, 0, 1]
                          [0, 0, 0, 1, 0, 1, 0, 1]            [0, 0, 0, 1, 0, 1, 0, 1]
sum = 0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1...
In this example after an initialization period of length 3, we get a stable 
pattern with a yield of 1

However I could not find a pattern for the following vectors and I am searching for an algorithm that could identify the best pattern for any such one:

[0, 0, 2, 3, 2]
[0, 0, 2, 0, 3, 0, 4, 0, 2]

Precision 1: The vector will always start with at least a zero, but there can be many more, and it will always finish with a value above zero.

Precision 2: The solution should be the shortest periodic design that allows a stable sum of yield.

Retry at the problem specification: We have a production mean 'A' to grow plants. Each plant has specs as to how it grows, represented by a given vector as presented above. For a given 'A', once a plant production cycle is over, you can start a new one. We want to model a stable plant production with as few 'A' as possible.

$\endgroup$
  • 2
    $\begingroup$ If you have sth like [a, b, c ....m], if you always shift by 1, after the initialization period of m - 1, you get consistently sum of all values, right? So this is the shortest periodic design (always shifting by 1) and it allows a stable sum yield. But it seems too easy, so is there perhaps some stricter requirement? Would a shorter initialization period with a longer pattern be better? $\endgroup$ – Mederr Jul 19 '18 at 12:36
  • $\begingroup$ Simple approach that I'll implement for now. However, I am looking for an algorithm that will use a minimum of vector repetition to reach a periodic solution, making it more modular. With your solution, and the first vector [0, 1, 2, 3, 2], you need 5 such vectors to accomplish a periodic cycle and the constant yield is 7 while mine requires 'only' 3 vectors and has a yield of 4. In your solution their is no empty space which is cool but we don't need this constraint since we can use empty slot to fit other vectors once we know the length of the empty slot. (am I clear?). Thank you btw ! :) $\endgroup$ – Yohan Obadia Jul 19 '18 at 13:09
  • $\begingroup$ when you mentioned "shortest periodic design", i thought this means the design with the shortest period. For example, in first case the period would be (shift 2), after which it repeats, in the second case the period would be (shift 1; shift 5), after which it repeats. But then this is not what you want to optimize. So what you want is to use as few vectors as possible before you get a consistent sum? And the value of the sum doesn't matter either? $\endgroup$ – Mederr Jul 19 '18 at 13:22
  • $\begingroup$ That is exactly right ! You formulate it better than I do. The point is that having empty spaces is fine because we can always fill them with the desired product with a shorter vector. $\endgroup$ – Yohan Obadia Jul 19 '18 at 15:38
  • 1
    $\begingroup$ I don't understand the problem statement. Can you specify it more precisely? What exactly does "combine this vector with itself" mean? What exactly is the definition of "stable" and "most possibly stable"? Under what conditions is a solution periodic? A few examples is not a substitute for a clear and general specification of the problem. $\endgroup$ – D.W. Jul 20 '18 at 5:01
1
$\begingroup$

Made up rule nr 1: Every number has to be part of the sum. Therefore the sum cannot be x, if there is a number b, such that no combination of numbers can add up to x-b.

So for [0, 0, 2, 3, 2]:

  • the sum cannot be 2 (because 3 cannot be part of that)
  • it cannot be 3 (because 3 - 2 = 1 and there is no combination of numbers that add up to 1 (rule 1))
  • it cannot be 4 (because 4-3 = 1 again, (rule 1))
  • it cannot be 5 (because there are twice as many 2-s as 3-s)
  • it cannot be 6 (because in case of 3-s, only two rows in exactly the same place can make up that number, and the 2-s would then form 4-s, which cannot sum up to 6)

Therefore for the specific case of [0, 0, 2, 3, 2], the simplest solution is to have the value of 7

Perhaps this complicated reasoning helps to consider the future vectors as well :)

[0, 0, 2, 0, 3, 0, 4, 0, 2] is more difficult though. While not considering too thoroughly, it looks like for that as well, there isn't anything better than the trivial solution.

Trivial solution:

[a, b, c ....]
   [a, b, c ....]
      [a, b, c ....]
      ...
| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Your rule define what the constant summing-section value will be but not how you place the vectors in a way that ensures the production stability. The only solution here is the trivial one that I actually like for its simplicity but it is not enough in the long run for us. (so just an upvote :p) $\endgroup$ – Yohan Obadia Jul 19 '18 at 15:43
  • $\begingroup$ My point was that i think for the specific vectors [0, 0, 2, 3, 2] and [0, 0, 2, 0, 3, 0, 4, 0, 2] there doesn't seem to be anything better than the trivial solution. I wrote how i came to that conclusion, so that if you cannot find any better algorithm than the trivial, you could similarly analyze future vectors by hand to see if you can find any better solutions for them. Or perhaps the manual analysis helps you to write the algorithm yourself :D $\endgroup$ – Mederr Jul 19 '18 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.