157
Views
0
CrossRef citations to date
0
Altmetric
Received 20 Feb 2020, Accepted 17 May 2024, Published online: 11 Jun 2024

Abstract

A solar car needs 5 fully charged batteries to run, and it depletes those batteries in 5 hours. The batteries are rechargeable, and solar panels on the car are able to charge 3 batteries simultaneously. It takes 3 hours for the solar panels to finish charging 3 batteries. Furthermore, batteries cannot be charging and in use at the same time. If the car always starts running as soon as 5 full batteries are available, and the solar panels can only operate if 3 empty batteries are available, how many batteries are needed so that the car can eventually run without stopping? We investigate this resource optimization problem and its different variations.

Systems often have inputs and outputs that utilize the same resources, and it is a common problem to minimize the amount of resources needed to reduce costs. For example, consider the following problem about a solar car. The car needs 5 fully charged batteries to run, and it depletes those batteries in 5 hours. The batteries are rechargeable, and solar panels on the car are able to charge 3 batteries simultaneously. It takes 3 hours for the solar panels to finish charging the batteries. Furthermore, batteries cannot be charging and in use at the same time. If the car always starts running as soon as 5 full batteries are available, and the solar panels can only operate if 3 empty batteries are available, how many batteries are needed so that the car can eventually run without stopping?

As a model for this rechargeable car battery problem, we consider a system of buckets that handle a certain kind of flow (electricity in the case of batteries, but the flow could also represent water, work, etc). The size of each bucket is 1. Each bucket has an inlet and outlet, and at most one of them is active at any moment; this corresponds to the restriction that the batteries cannot be in use and also be charging at the same time. Additionally, there is an inflow and outflow in the system, which each have a constant total flow speed of 1 per time unit. In the car battery problem, the solar panels correspond to the inflow (charging the batteries), running the car corresponds to the outflow (depleting the batteries), and the time units are measured in hours.

Let I and O be two positive integers dictating how the inflow and outflow of the system operate, respectively. When a bucket inlet is active, the inflow speed to the bucket is 1I; and when the outlet is active, the outflow speed is 1O. The total input flow speed is 1; hence, I buckets are needed to accommodate the inflow. Similarly, the total output flow speed is 1; hence, O buckets are needed to produce the output flow. The inflow would therefore fill up I buckets in I time units, and the outflow would deplete O buckets in O time units. The system runs as follows.

  • At time 0, all buckets are empty. This is the initial bucket condition.

  • The input flow starts filling up I empty buckets at time 0 (the inlets of these I buckets are activated). When these I buckets are filled up (after I time units), another set of I empty buckets (if available) will immediately be allocated to take the input flow. If there are not I empty buckets, then the input flow stops until there are I empty buckets again.

  • At some point when there are O full buckets, the output flow initiates; the outlets of these O buckets activate and the output flow continues until they become empty (after O time units). Note that the initial output flow starts after OI·I time units (when at least O full buckets become available for the first time). When these O buckets are completely emptied (at which point they can again be reused for input flow), then the output flow initiates on another set of O full buckets (if available). If there are not O full buckets, then the output flow stops until O full buckets become available again.

Definition

(Stable Flow). Given enough buckets, both the inflow and outflow will eventually run continuously, since the inflow and outflow speeds match (both are 1). We will call flow with nonstop inflow and outflow stable flow.

We would like to find Bmin, the minimal number of buckets needed in the system such that a stable flow can eventually be reached.

We consider the following problems:

  1. The base case (as described above): given I and O, find Bmin.

  2. The case with a threshold T for initiating the output flow. In the base case, the output flow starts as soon as there are O full buckets. For this case, the output flow only activates when there are T full buckets, where TO (in the base case, T = O). Given I, O, and T, find Bmin.

  3. The case with F0 initially full buckets at time 0. In the base case, there are 0 full buckets at time 0. For this case, there are F0 full buckets at time 0, where O>F00 (in the base case, F0=0). Given I, O, and F0, find Bmin.

  4. The case with both a threshold T and F0 initially full buckets. This is the most general case, combining the two above cases. In this case, we relax the restraint on F0 to be T>F00. Given I, O, T, and F0, find Bmin.

It will be enough to solve case 4, since the other problems are special cases of case 4.

Example

For the car battery problem, the solar panels charge 3 batteries in 3 hours, so I = 3. The car runs on 5 batteries and depletes them in 5 hours, so O = 5. The car is able to run as soon as there are 5 fully charged batteries, so T = 5. Finally, there are no initially charged batteries, so F0=0. The system progresses as follows.

  • At time 0: the input flow starts filling buckets 0, 1, 2.

  • At time 1: buckets 0, 1, 2 are 13 filled.

  • At time 2: buckets 0, 1, 2 are 23 filled.

  • At time 3: buckets 0, 1, 2 are completely filled; not enough full buckets are available for the output flow, while the input flow starts filling buckets 3, 4, 5.

  • At time 6: buckets 0, 1, 2, 3, 4, 5 are completely filled; the output flow starts draining buckets 0, 1, 2, 3, 4, while the input flow moves on to buckets 6, 7, 8.

shows the system at time 6.

Fig. 1 The example system at time 6. The input flow activates on buckets 6, 7, 8, and the output flow begins draining buckets 0, 1, 2, 3, 4.

Fig. 1 The example system at time 6. The input flow activates on buckets 6, 7, 8, and the output flow begins draining buckets 0, 1, 2, 3, 4.

Solution

It is clear that having an unlimited number of buckets would eventually allow the system to have both flows run nonstop. So, we first assume that there are an unlimited number of buckets, and then find the maximum number of the buckets that are in use at once, which would be Bmin.

Definition

(States). Given PO such that 0PO<O and PI such that 0PI<I, we represent the state of the system where F buckets are full, O buckets are POO full, and I buckets are PII full by S(F,PO,PI). In such a state, the output flow has been running on its current set of O buckets for OPO time units, and the input flow has been running on its current set of I buckets for PI time units.

According to rules described by the problem statement, the state S(F,PO,PI) transitions to a new state after 1 time unit as follows.

  • If PO = 0 and FT, then in the next state F decreases by O and PO becomes O – 1.

  • If PO = 0 and F < T, then the outward flow stops, so PO stays at 0.

  • If PO0, then PO becomes PO1.

  • If PI=I1, then in the next state F increases by I and PI becomes 0.

  • If PII1, then PI becomes PI+1. Even if PI = 0, the input flow will still be guaranteed to continue because we assume there are an unlimited number of buckets; so, there will always be enough empty buckets to accommodate the input flow.

  • In the case where both PO = 0 and PI=I1, F would transition to F+IO.

By definition, stable flow consists of nonstop outward and inward flows. Therefore, when the stable flow first starts, the output flow must have previously been stopped, and the input flow must have just finished completely filling enough buckets to allow the output flow to activate. This corresponds to a state of the form S(n,0,0) at the beginning of the stable flow (for some positive integer n).

Definition

(Stable States). Call a state S(F,PO,PI) stable if using this as the initial state allows the output flow to never stop (the input flow already runs continuously because of our assumption that there are an unlimited number of empty buckets). In other words, any stable state induces stable flow.

Note that all states that appear in the stable flow would be stable. Since the outward flow never stops, then PO iterates through the numbers 0,O1,O2,,1, while PI loops through the numbers 0,1,2,,I1. Consequently, the cycle of states during stable flow has length lcm(I,O). Furthermore, for each state S(F,PO,PI) that follows, the sum F+PO+PI is invariant, since the inward flow rate matches the outward flow rate, and both flows never stop.

The progression of states in the car battery problem is shown in the following tables.

In this example, the stable flow starts with S(7,0,0) at time 12, and S(7,0,0) reappears at time 27, so the stable flow has cycle length 2712=15=lcm(3,5). We can see that S(7,0,0) and S(3,3,1) are stable states, but S(6,0,0) is not stable because the outward flow stops between time 11 and 12.

Throughout the rest of the proof we let d=gcd(I,O).

Lemma 1.

Let x be a positive integer and k be a nonnegative integer. If the state S(xk,0,k) appears after S(x,0,0), then d|k.

Proof.

First, we claim that both the inflow and outflow do not stop in the time between S(x,0,0) and S(xk,0,k). Although S(x,0,0) need not be a stable state, the fact that (xk)+0+k=x+0+0 means that both inward and outward flows do not stop during the time between the 2 states. Suppose it takes t time units to get from S(x,0,0) to S(xk,0,k). As both the inflow and outflow do not stop for the time between the 2 states, then PO and PI cycle in the manner mentioned earlier, so we have t0(modO)and tk (modI).

Let t = aO and t=bI+k, so that k=aObI. We have d|aO and d|bI; therefore d|aObI, i.e., d|k. □

Lemma 2.

S(x,0,0) is stable if and only if xT+Id.

Proof.

Consider the states of the form S(xk,0,k) that appear after S(x,0,0). By Lemma 1 we have d|k. Combined with d|I and 0k<I, we get 0kId.

If S(x,0,0) is stable, we know that the output flow never stops. Thus, at any state S(xk,0,k), we must have xkT so that there are enough full buckets to accommodate the output flow. Conversely, if we have xkT for all possible states S(xk,0,k) that come after S(x,0,0), then the output flow never stops so we know S(x,0,0) is stable.

If xT+Id, then for all possible k, xk(T+Id)(Id)=T, so the state S(x,0,0) is stable.

Now assume S(x,0,0) is stable. By Bézout’s lemma [Citation1, p.7–11], there exist integers m, n such that mO + nI = d. Since mO+nI=d(m+I)O+(nO)I=d, we can stipulate without loss of generality that m > 0 by repeatedly adding I to m and subtracting O from n as needed. Now we have (Id)mdO+(Id)ndI=Idd(mO+nI)=Id.

If we let t=(Id)mdO, then t0(modO) and tId (modI). Then the state at t=(Id)mdO after S(x,0,0) is S(xI+d,0,Id), since the inflow and outflow run continuously. By our earlier work we must have xI+dT; hence, xT+Id. This concludes the proof of Lemma 2. □

Lemma 3.

If x<T+Id, then S(x,0,0) is eventually followed by the state S(x,0,0), where x<x<T+I and xx(modd).

Proof.

By Lemma 2, x<T+Id means S(x,0,0) is not stable, so by the definition of a stable state, the output flow stops at some point. Thus, there exists a state S(xk,0,k) that appears after S(x,0,0) such that xk<T. From here, the output flow ceases, so S(xk,0,k) is followed by S(xk,0,k+1),S(xk,0,k+2),,S(xk+I,0,0).

Let x=xk+I. From k < I we have x<x, and we also have x=(xk)+I<T+I. Finally, by Lemma 1, d|k. This, combined with d|I, yields x=xk+Ix (modd). This completes the proof of Lemma 3. □

Lemma 4.

Let y represent the unique number such that yF0(modd) and T+Idy<T+I. Then starting from the initial state, eventually the stable state S(y,0,0) is reached.

Proof.

Let x0=F0<TT+Id, so that the initial state is S(x0,0,0). For any nonnegative integer i, we let the next state after S(xi,0,0) (in chronological order) that is of the form S(x,0,0) be S(xi+1,0,0). By Lemma 3, we know the sequence {xi} exists and is strictly increasing until we have some xN such that T+IdxN<T+I for the first time. At this point S(xN,0,0) is stable by Lemma 2, so it starts the stable flow, and {xi} becomes constant. Also by Lemma 3, the sequence {xi} is constant modulo d, so xNx0F0(modd). This implies y = xN, so S(y,0,0) is a stable state that is eventually reached. □

Remark.

Because Id0(modd), we can find y=T+Id+((F0T)(modd)),where the remainder is nonnegative and less than d.

Solution to original problem

Finally, we will answer the original problem. Let y be defined as in Lemma 4. As mentioned earlier, finding Bmin is equivalent to finding the maximum number of buckets that are required for any individual state to continue in the repeating cycle induced by S(y,0,0).

First let us suppose PO0. At any state S(F,PO,PI) with PO0, there are F full buckets, O buckets required to accommodate the outward flow, and I buckets required to accommodate the inward flow (even if PI = 0, there must be I empty buckets available for filling). Therefore, for PO0 it suffices to maximize F. Since F+PO+PI=y is invariant, then we must minimize PO+PI. Let the state S(F,PO,PI) occur t time units after S(y,0,0). Then tOPO(modO)and tPI(modI).

Suppose t=aOPO and t=bI+PI. Then PO+PI=aObI, so since d|aO and d|bI, then d|PO+PI. Since PO0 then PO+PI>0, so PO+PId. Therefore, Fyd.

We now show this maximum is achievable. By Bézout’s lemma [Citation1, p.7–11], there exist integers m, n such that mO + nI = d, so (Od)mdO+(Od)ndI=Odd(mO+nI)=Od.

If we let t=(Od)ndI then we get PO = d and PI = 0, so PO+PI=d and F=yd achieves the maximum possible value of F. This yields a total of yd+I+O buckets as the maximum amount of buckets in use at once (for the case of PO0). In the example presented earlier, (y,d,I,O)=(7,1,3,5). The state requiring the most buckets is S(6,1,0), which uses 71+3+5=14 buckets.

Now suppose PO = 0. At any state S(F,0,PI), F + I buckets are necessary to allow both flows to continue running. However, F+Iy+Iyd+I+O, so at most yd+I+O buckets are in use for all of these cases as well.

Therefore, Bmin=yd+I+O. However, recall that y=T+Id+((F0T)(modd)). The following theorem sums up all of our work.

Theorem 1

(Minimum number of buckets required for stable flow). Let a bucket system be defined by the input flow parameter I, output flow parameter O, threshold TO, and initial number of full buckets 0F0<T, and let d=gcd(I,O). The minimum number of buckets required to eventually allow the system to have both input and output flows run nonstop is Bmin=2I+O+T2d+((F0T)(modd)).

The remainder modulo d should be interpreted as nonnegative and less than d.

Using our theorem, we can simplify the expression for Bmin for the 4 proposed problems as shown in the following table (with even more simplification when d = 1).

As in the theorem, all the remainders modulo d should be interpreted as nonnegative and less than d.

Going back to the car battery problem, which has (I,O,T,F0)=(3,5,5,0) and d=gcd(3,5)=1, the theorem tells us that 2·3+2·52=14 batteries are necessary to allow the car to eventually run without stopping.

Additional information

Notes on contributors

Raymond Feng

Raymond Feng ([email protected]) is currently a second year undergraduate studying Computer Science and Mathematics at MIT. He is most interested in combinatorics, number theory, and theoretical computer science. In his free time, he enjoys playing ultimate frisbee with MIT’s Grim Beavers.

Reference

  • Jones GA, Jones JM. Elementary number theory. Berlin, Germany: Springer-Verlag; 1998.