A Framework for Object Oriented Simulation [OOS]
Copyright Jack Strom 2021
The Human Genome Project has made available a massive database of information on the blueprint of human life. A flood of data in the various fields of biology has led to a systems approach whose goal is to integrate biology, mathematics, and engineering in its efforts to understand and utilize the massive amounts of “information on genes, proteins, cellular dynamics, and organisms’ responses to … the environment” [1]. A deluge of information is also being collected in fields such as physics, meteorology, economics and a host of other disciplines. The next step is to integrate this data into models and simulations that will allow us to explore, understand, and make predictions at the systems level. Object Oriented Simulation [OOS] is the natural approach to utilize this data to both model and build simulations at the systems level. It is an approach that is equally applicable to the diverse fields of biology including neuroscience, epidemiology, and forestry; and also to the field of economics such as the study of market behavior. But what is OOS?
Definition of Object Oriented Simulation [OOS]
Object Oriented Simulation (OOS) is the technique of modeling real world systems and their processes using software entities that are analogues of those real world entities whose activities and interactions result in the phenomena and behaviors of the systems which we are attempting to model. The system may be a forest, the membrane of a cell, or a financial market, as well as a host of other phenomena. The interactions and behavior we may simulate could include the purchases and sales of a limited resource; the molecular interactions among various sub-cellular structures; or the “arms race” between preys and predators. Some phenomena which we may be interested in modeling would include how an infectious agent could spread in a vulnerable population; or how the asymmetries of information could affect the returns of various market participants.
Benefits of Object Oriented Simulation
Some of the major benefits of Object Oriented Simulation (OOS) include reducing the complexity of the simulation model; generating explainable models; clarifying relevant factors important to the understanding of the phenomena under study; and generating new hypotheses amenable to experimental verification.
A simulation created using the techniques of OOS results in a model that is less complex and therefore easier to change and to scale up to more complex problems. Let us look at an analogy from biology to understand the reasons for this. The biological cell reduces the complexity of maintaining its existence by partitioning itself into compartments and components specialized for specific functions. An example of this would be the mitochondria which are the energy plants of the cell. This encapsulation of form and function simplifies the cell’s response to its immediate environment. Each component of the cell no longer needs to know all the internal workings of all the other components. This simplifies the behavior of each component, but still allows for a great deal of diversity in the repertoire of responses with which the system as a whole (the cell in this example) can respond. In a similar manner in OOS, the modeler partitions the problem into a set of simulation objects each with a specific set of logically related states and a set of simple rules that govern the transition between those states. The simulation, just as the cell, also provides the locus in which the objects can interact. Unlike traditional simulation techniques, OOS is not attempting to come up with equations that explain the behavior of the system as a whole. Rather, the effort is to derive a set of simple rules and states for the simulation objects, and then validate the model by comparing the complex behavior that emerges against the natural phenomena that is under examination.
One of the most important functions of a model is to explain the cause of the phenomena. The techniques of OOS help to develop models that are easier to explain. This is because of the close correspondence between the simulation objects, their states and the rules under which they change state, and the components of the phenomena that they are attempting to model. This close correspondence is not as apparent in other techniques such as neural networks.
The states and rules of the simulation objects derive from a study of the phenomena itself. Therefore, the process of specifying the simulation objects and their behavior helps to clarify those factors relevant to explaining the phenomena. But not only does the process help the modeler to better understand the phenomena, the comparison of the results of the simulation to the phenomena should also lead to hypotheses which can be tested experimentally. In the real world, it may be more difficult to isolate the different factors that affect the phenomena. Although the benefit of a controlled environment is one shared by many simulation techniques, OOS also provides the means of observing how a large permutation of possible interactions among objects defined with simple states and rules of interaction can result in emergent complex behaviors.
Basic Components
The basic components of an object oriented simulation (OOS) include at least one class of simulation objects; one or more controllers which will be used to sequence the interactions between instances of simulation objects; and one or more grids (or at least a “non-spatial” entity) used to group the instances of simulation objects.
Grids
The “grid” is primarily a spatial entity. More specifically, it is a 2 or 3 dimensional map on which a simulation object may move. And it is through the facility of this map, that the simulation object can also determine the location of other simulation objects. It is this ability of the grid which allows a simulation object to “sense” the presence of other simulation objects and thus allow our simulation object its ability to interact with other simulation objects and manifest its behavior. In turn, it is the collective manifestation of the behavior of all the simulation objects of the system that gives rise to the emergent properties of the system. Some examples of a grid would include: a cellular membrane, a forest, a city.
There are two types of grids: simple spatial and meta spatial. A “simple spatial grid” provides the basic spatial facilities discussed above, namely that of a 2 or 3 dimensional map. Its function is simply to keep track of the position of each simulation object, and thus define the space in which these objects can act. An example of this type of grid could be a simplified cellular membrane on which molecular objects could move and interact.
A “meta spatial grid” inherits the properties of a “simple spatial grid” in that it too has the facilities to locate all simulation objects, and thus allow motion and interaction. However, it has additional properties and operations. Similar to how “metadata” in a schema contains information about the data and how that data may be modified, a meta spatial grid contains parameters (i.e. properties) and rules that may modify the interactions among simulation objects that occupy that meta spatial grid. In addition to providing a matrix in which interactions can take place, the meta spatial grid may enforce rules regulating entrance to and egress from its matrix. This grid might also specify the rate of interaction among
simulation objects on its matrix. As an example, the simulation objects of an epidemeological model could occupy a meta spatial grid. In such a model, there would be different meta spatial grids, each with their
own frequency rate of exposure: high rates of exposure to a pathogen for grids representing the workplace; low rates for grids representing relatively open spaces.
The grid itself does not affect simulation objects on other grids even if these grids are in
apposition to that grid. Rather, it is the simulation objects themselves which can affect those simulation objects that are in apposition. It is the properties and rules of these simulation objects in the “grid cells” and not the “cells” themselves that affect the interaction. In other words, the grid may affect the number of interactions a simulation object might experience, it may even affect the extent of the area, that is, the “neighborhood” over which a simulation object has its effect, but it does not affect the interaction itself which is governed by the internal rules and properties of those simulation objects involved in the interaction. This principal derives from a fundamental aspect of object oriented simulation: global behavior arises from local interactions. As an example, take the “concentration gradient”, a key aspect of developmental biology. This gradient could be modeled by distributing the same simulation objects over a grid, in increasing density in a particular direction, or by distributing the same density of simulation objects but with increasing amounts of a specific factor ordered in a particular spatial direction. It would not, however, be modeled by changes in the properties of the cells that held those simulation objects.
Separating these responsibilities of the grid from those of the simulation objects in this manner has the conceptual advantage of matching the behavior expected of a particular object to that behavior which that object has authority to change. In other words, matching responsibility with authority. It also has the
computational advantage in that the objects so created have less dependencies on one another, that is, are less coupled, and therefore, more reusable. Since it is the simulation object, and not the grid itself, that is responsible for understanding how and when it is to respond to specific events, the code that is produced is
simpler to code and to modify.
When determining how many grids, or spaces, to model in an Object Oriented Simulation, one should keep in mind the following principal: within the confines of modeling which must, by necessity, be an abstraction process, every effort should be made to create programming constructs which correlate as closely as possible to the real world objects that they attempt to model. If we take the stock market example, where buyers and sellers are trading in a single space, there would be only a single space. If we considered the biological simulation of a neuron and a muscle fiber, we might have one grid representing the membrane of the muscle cell (postsynaptic membrane), a second grid representing the membrane of the neuron (presynaptic membrane), and a third grid representing that matrix of elements interposed between the two membranes (basal lamina).
Another problem is how to model objects whose corresponding real world instances have a difference in relative size. An example of this would be modeling the dynamics of two molecules where one molecule (Molecule A) was 5 times the size of the other (Molecule B). If we depict each molecule as being 1pixel wide by 1 pixel high on a single grid, then this size difference would interfere with the possible number of interactions Molecule B could have with Molecule A. One solution to this problem would be to populate each grid only with molecules of the same size, and then provide transform functions that would scale the “effect” of one sized molecule inhabiting one grid onto a different grid with a different sized molecule. Let us see how this would work with our above example where Molecule A is 5 times larger than Molecule B. Molecule A inhabits Grid A and Molecule B inhabits Grid B. When we wish to determine which of the Molecule B’s will affect a particular Molecule A, we would transform the location of Molecule A on Grid A to a corresponding location on Grid B. We would then use this location on Grid B as the central point of a 5×5 rectangular array which would encompass all of the Molecule B’s which we were interested in examining as to their “effect” on Molecule A. In other words, we have increased the size on Grid B to correspond to the size of Molecule A.
If one can think of a space where there are certain rules of interactions, but where the spatial dimensions are irrelevant, then one might fruitfully apply the concept of “meta” properties to that space. A market could be thought of as such a space. A “virtual” market place could be such a space in which buyers and sellers interact, though they may never physically meet. The Internet auction site of
eBay and the securities market of the Nasdaq are examples of such a “virtual market space”. In such
spaces as these, there are rules of interaction: rules such as qualifications for entry into the market space, specifications for what constitutes a sale, and protocols for how participants may post and respond to offerings. These rules would constitute the meta data of that market space. Such a space should be considered as a “meta space” although not a grid.
Controllers
A controller determines the order in which a simulation object either acts on or is acted upon by another instance of a simulation object. The sequence in which the controller invokes each simulation object to perform its repertoire of actions should be shuffled at each iteration of the simulation to allow for a random order in which the sequence of actions take place. A controller could be thought of as a list of instances of one or more classes of simulation objects. The controller itself has no knowledge of the actions each simulation object will take. The controller merely invokes each simulation object’s “move” routine and then the simulation object itself performs its unique actions based on any one or more of the following: the object’s own state, the state of other simulation objects in its “neighborhood”, and the methods which it has to transform its state and possibly the state of other simulation objects.
Normally, there would be only one controller. However, there may be times when we will need to create multiple controllers. This could occur when one set of simulated actions would need to take place during an initial stage of development before a different set of simulated actions occur. A biological simulation where different phases of development are being modeled could be such an example. When multiple controllers exist, it is convenient to have a governor which sets down the rules in which each controller executes.
Simulation Objects
The main actors of an OOS are the simulation objects. It is through each simulation object’s activity and the interactions it has with other instances of simulation objects that the behavior of the system emerges. It is convenient to separate the functions of creating a simulation object from that object’s actual activity in the simulation. A “simulation object factory” is used for this purpose of instantiating a particular simulation object. There is a unique “simulation object factory” for each type of simulation object. A simulation object would normally be associated with at least one controller when it is created since only those objects associated with a controller participate in the simulation. In order to better understand simulation objects, you need to understand the OOS model building process.
OOS Model Building Process
The following steps are involved in the OOS model building process:
First, you must determine what are the important simulation objects relevant to the phenomena that you are trying to simulate. If you were to simulate a market, the relevant objects might be buyers and sellers. For the simulation of a forest, you would probably include the different trees in that forest. Which objects you include depend on the questions that you are trying to answer with the simulation. If you were modeling deforestation, only modeling trees would be insufficient. You would also need to include objects that affect the growth, reproduction and death of these trees. This might include insects and other animals that feed on the trees.
Next, you will need to determine the relevant attributes of each simulation object. The combined values of all of the attributes of the object will define the state of that object. And all the allowable combinations will define the set of possible states that object can manifest. Attributes might include the age of a tree, whether a host has immunity, the amount of financial resources of a buyer, the energy level of a predator. Once again, you need to look at the questions you are trying to answer when determining which attributes to model. Whereas age might be significant to modeling the succession of trees in a forest, it may be irrelevant when modeling buyers and sellers in a commodities market.
You must next determine the rules by which each object will transition from one state to the next; and that set of actions that that object will take in each state (the object’s behavior). An object can only be in one state at any given point in time. However, it may take multiple actions while in each state. And the action(s) could affect both the objects own state as well as the state of other objects. A probability that the action is executed is associated with each state that could result in that action being taken. A probability is also associated with the occurrence of a transition from one state to the next given a specific action. If the object executes the action every time it manifests a given state, or a state transition occurs every time the action is executed, then the associated probability would be 100%. Often, however, the probability would be less than 100%. As an example, a predator that is hungry (a specific state of the predator), with a prey nearby, may attack (a behavior of the predator) 70% of the time. A prey that is slow (an attribute of the prey) may be killed 80% of the time that it is attacked (a state transition for the prey) and that kill may result in a given increase in the energy level of the prey 100% of the time (a state transition for the predator).
Next, you need to determine whether there is to be an order in which each object is to “make its move” or whether it is to be random. And then you must define what constitutes one complete cycle. You may additionally need to define the time scale of each cycle and the unit distance of each move.
Each simulation object has a repertoire of actions that it can take. The set of actions the simulation object takes during each cycle is dependent upon the conditions in its environment and its internal state. The complete set of actions that it takes together with all the state transitions that it undergoes is what I have termed “making its move”. A complete cycle will usually be defined as the opportunity for each simulation object to “make its move”. Notice that have I said “opportunity”. Not every simulation object needs to “make its move” during each cycle. In fact, different types of simulation objects could “make their moves” after a different number of cycles if they have different rates of activity. (This could be one way to model molecules with different kinetics.) Since the order in which each simulation object “makes its move” can be important, it may be necessary, after each cycle, to randomize the order in which each object is called upon to make its move.
Since we are trying to simulate and predict real world phenomena, it may be necessary to attach a time scale to each cycle of the simulation. This time scale may equate a single cycle to a nanosecond, a day, or even an epoch. The time scale that we choose for each cycle will often be dependent upon the time scale we have used to gather data and the unit of time over which our phenomena can change its state. If we have tracked the number of infections that a naïve population is exposed to each hour of the day, then each cycle might be equated to an hour.
Often it is important to understand the size and distance relationships in the phenomena we are studying. Since the smallest unit of a grid is the cell, it would be necessary to estimate the size of a cell in the simulation grid. If we have defined a unit of time for each cycle, then the unit of distance could be how far that object moves in that unit of time. Alternatively, if our simulation has resulted in structures that are similar to structures in the real world that we are trying to model, then we can use the measure of these real world structures to scale distances in our simulation. As an example, let us say that we are simulating the aggregation of a particular set of molecules. If we observed a simulated cluster that was similar to a biological cluster, we could determine the actual size of the biological cluster in some unit of measure (such as microns), determine the size of the simulated cluster in number of pixels (assuming that 1 cell equated to 1 pixel), and then determine a size factor by dividing the biological cluster size by the simulated cluster size. We would then have a usable ruler with which to estimate distance and size in our simulation.
It is not always important to specify time or distance. In the simulation of a market, probably neither of these dimensions would matter. In such a context, a cycle might be defined as every market participant being allowed to make one bid or ask on one or more resources.
Once you have completed a simulation, you will need to analyze the patterns that emerge from the simulation and compare these patterns to the phenomenon that you are trying to model. If the correspondence between your model and the actual phenomenon is inadequate, you may need to enrich the model by adding new objects, adding new relationships among the objects, or adding new attributes and actions to the existing simulation objects.
Future Plans
Object Oriented Simulation (OOS) is a technique with tremendous potential. However, for that potential to be realized, there needs to be developed a library of simulation objects in the various fields such as science and economics. The attributes, actions and probabilities of action of the simulated objects would need to be specified by researchers based on the data they derived in their experiments. Data specifying attribute values and probability of actions could be codified in a specialized version of XML standardized for that particular discipline. We now have a deluge of data on life and its processes. The next step is to use that data to predict and to understand this information.
[1] Tracing Life’s Circuitry, Science, 5 December 2003, Vol. 302