In this post I consider some ideas on data visualization for python simulations.

 

This data visualization concept which I am talking about is not the one which we typically encounter at the end of a simulation run when we have a set of collected data which we plot and analyze using various statistical means.  What I am really interested in is, the visualization ( and animation ) of runtime data structures of a simulation model during the simulation run which can present a very intuitive view to the user about the internal working of the model. This way we actually get to see , how our main data structures are getting changed / altered during the runtime to get a decent picture of the model performance and this can also help in debugging.

 

Just to give an example to get the things more clear, we are aware of the TCP sliding window protocol. Now , if we have a simulation model for the sliding window protocol , then obviously we will be having a data structure for maintaining the sliding window. In python this could be a list or a set data structure.    So, during runtime, the sliding window data structure will encounter various operations like addition , deletion of packets ( or sequence numbers ) and sliding through the data and increasing/decreasing the size of the window etc, etc.  If we can standardize a set of visual representations for these operations and a set of animations for representing the data changes on the data structure then this can act as a very effective framework to analyze the data at runtime.  

 

To develop such a standardized framework we have to consider some commonalities between the data structures.

-  All the data structures are essentially sequences of data .

-  All the data structures provide facilities to add and delete single or multiple data sequences. (An exception is a tuple which we will discuss about later ).

 

Next we examine the exceptions and special cases for some data structures.

- We also deal with primitive data like an integer float or a character. These can be considered as special cases of single data sequences.

- There are certain data structures which are immutable as in the case of a tuple in python. So the visualization framework needs to be aware of it.

 

- We also encounter strictly defined sub sequences within sequences in data structures. A typical example if this is the dictionary. Here we always have multiple key value pair sequences as part of the main data sequence of the data structure.    

 

Considering the above commonalities and  the exceptions , we can design a visualization framework with the following basic features.

- The framework will be attached to a set of python variables containing the data structures and will monitor them.

- The framework will be aware of immutable data types and special strict sequencing of data structures like a integer ( a single value sequence ) or a dictionary ( a sequence of sub sequences containing a key and value ).  

 

- The framework will support animation sequences for every change in the data within a    sequence.   

 

- The framework will support special highlighting whenever the sequence is modified ( data added, deleted , changed ). This will also apply to special strict sequences and immutable datatypes in the following ways.

- In case of single value data structure , the framework can display the new value of the              data along with the sequence of previous values or the diff of previous value.

 

-  In case of strict sub sequences , the framework can display the non constant part of                the sequence as a single value data structure as mentioned above. For example , in a                dictionary the key will always remain constant whereas the value of the key will                        change.  So this value can be treated as a single value data sequence.

  -  In case of immutable data types like tuples, the framework will keep a tab of the variable    containing the data and will have a animation or highlighting sequence defined whenever            the variable is reassigned to contain a new tuple sequence.  

- The framework will support the enabling / disabling of display of a sub section of the sequence by defining a pair of bounds ( upper and lower bound ) for the data structure sequence.

 

- The framework will support the enabling / disabling of highlighting  of a sub section of the sequence by defining a pair of bounds ( upper and lower bound ) for the data structure sequence.

 

These are some of the basic features which I can think of , based on the sliding window example. I will extend this list with a few more features which may seem desirable.

In my next post I will try to come up with some ASCII based simple diagrams of the visualizations which I have discussed here.  I hope that will make more sense to the readers rather than going over the descriptions here,as they say "A picture is worth a thousand words" .