Matrix Implementation of Bathtub Models
Overview
Linear Algebra Formulation
In a basic
linear algebra formulation, the variables being modeled are arranged in a column vector. That is, we would
create a state vector defined as follows :
{%
S= \begin{bmatrix}
W_1(t) \\
I_1(t) \\
O_1(t) \\
W_2(t) \\
I_2(t) \\
O_2(t) \\
\end{bmatrix}
%}
In this example there are two tubs
Next we create a matrix that describes how the state vector above evolves with each time step.
That is, we will want to find a matrix A such that
{% S_{t+\Delta T} = A S_t %}
We know that in the case of the two tub model above, we will need a 6x6 matrix. Given the basic setup, the matrix will
look something like the following, where the questions marks are to be filled in later.
{%
\begin{bmatrix}
1 & 1 & -1 & 0 & 0 & 0 \\
? & ? & ? & ? & ? & ? \\
? & ? & ? & ? & ? & ? \\
0 & 0 & 0 & 1 & 1 & -1 \\
? & ? & ? & ? & ? & ? \\
? & ? & ? & ? & ? & ? \\
\end{bmatrix}
%}
Here, the basic structure indicates that the change in the water in each tub is the input to that tub minus the output.
Next, we will have to fill in the question marks. That is, we will have to specify how the input and output flows
are determined from a prior state.
For example, if the inputs and outputs are assumed to be constant, then we will have the following:
{%
\begin{bmatrix}
1 & 1 & -1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 1 & -1 \\
0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
\end{bmatrix}
%}
Then the only remaining thing to do is to determing the initial state, that is, how much water is in each tub initially and
how fast are the flows into and out of each tub.
Bathtub Models
Economics
Money Flow