Algorithm to define min-Max ranges with some defined bound

44 Views Asked by At

Having to populate the following table of MIN-MAX cells, starting with only the knowledge of the IC value

enter image description here

I was thinking about a formula to get the values of A, B, C, D, E, F, G which works also for the values of IC and 2xIC

I'm able to get the values from 0 to IC using the following formula:

$$K = 3$$ $$LEVEL.MIN = \frac{IC}{K} \times (LEVEL-1)$$ $$LEVEL.MAX = \frac{IC}{K} \times (LEVEL)$$

I need another similar formula for the values of E, F, G, 2xIC. Maybe, since $E=IC$, the formula should have $+IC$ as a fxed part.

2

There are 2 best solutions below

1
On

Let's look at the conditions that you gave. You say that the MIN of level $n$ should be equal to the MAX of level $n-1$. Using this condition, we should rename the variables like so:

  • Level 1: MIN = 0, MAX = A
  • Level 2: MIN = A, MAX = D
  • Level 3: MIN = D, MAX = E= IC
  • Level 4: MIN = E, MAX = G
  • Level 5: MIN = G, MAX = 2IC = 2E

The next condition is that each level from 1 to 3 needs to have the same difference between MAX and MIN. In other words, $$ A = D-A = IC-D $$ From this condition we see that $D = 2A$ and of course $$A=IC-D \qquad \Rightarrow \qquad D = 2IC - 2D \qquad \Rightarrow \qquad 3D=2IC$$ The next condition is that levels 4 and 5 need to have the same difference between MAX and MIN. In other words, $$ G-E = 2E - G $$ Adding $E+G$ to boths sides, this is the same as $2G = 3E$. Now we can plug in these results to get the new level hierarchy:

  • Level 1: MIN = $0$, MAX = $A$
  • Level 2: MIN = $A$, MAX = $2A$
  • Level 3: MIN = $2A$, MAX = $IC$
  • Level 4: MIN = $IC$, MAX = $\frac{3}{2} IC$
  • Level 5: MIN = $\frac{3}{2} IC$, MAX = $2IC$

With these conditions, the hierarchy is left with two free variables, IC and A. But otherwise, the hierarchy now follows the conditions that you gave.

0
On

Ok, I finally got it.

enter image description here

The values from E to 2xIC can be calculated using the following formula: $$W=2$$ $$LEVEL.MIN = \frac{LEVEL-1-1}{W} \times IC$$ $$LEVEL.MAX = \frac{LEVEL-1}{W} \times IC$$