# Runtime of source with varying resource consumption

This question is regarding a simple problem, which can be posed for different physical situations. I am posing for a particular physical situation, but the idea is to exposit the general mathematical problem.

## The Problem

A device is running on an ideal battery of capacity $$C$$ (in mAh). It has a baseline current consumption of $$i_s$$ mA; it always consume this current at all times. There exist several "modes" for the device, which recur at fixed intervals, continue for fixed time and consume a given amount of current during that time. Multiple modes can co-occur. We can denote these modes by $$w_i$$. And their respective recurrence interval, runtime and current consumption as $$r_i$$, $$t_i$$ and $$i_i$$.

### Example:

To visually understand the problem and its modes, here is a simple example.

Let us take a device of $$10 Ah$$ capacity, with baseline current consumption $$i_s$$ = $$5 mA$$. It has the following modes.

$$\begin{array}{|c|c|c|c|} \hline Mode & r_i (s) & t_i (s) & i_i (mA) \\ \hline w_1 & 3*3600 & 1000 & 40 \\ \hline w_2 & 1.2*3600 & 2000 & 80 \\ \hline w_3 & 0.5*3600 & 500 & 200 \\ \hline \end{array}$$

Here is an image showing the current consumption of different modes over time: Here is an image showing the net/total current consumption over time: ### To Find:

We have to find the total run-time of the device (i.e. its battery).

### Solutions:

I have multiple solutions to this problem, some approximate (but analytical) and some numerical (iterative).

I want to know is there an analytical solution to this problem? Moreover, what tools are used to solve such problems? Can this be posed as an LP problem?