Saturday, August 28, 2010

Horses Use Mathematics

Horse's might be smarter than fifth graders. They use math frequently. The picture shows my daughter and niece lopping across Coogan's Ranch near Buena Vista, CO., in late July.

The lope (or relaxed canter) is a three-beat Western riding gait, meaning that there are three footfalls heard per stride. Each footfall is the "grounding" phase of a leg. The three footfalls are evenly spaced, and followed by the "suspension" phase of the gait, which is when all four legs are off the ground. The three beats and suspension are considered one stride. The movement for one stride is as follows:

1. Beat One: the grounding phase of the outside hind leg. There are many riders who think a front leg is the first beat of the canter, which is incorrect. At this time, the other three legs are off the ground.
2. Beat Two: the simultaneous grounding phase of the inside hind leg and outside fore leg. The inside fore leg is still off the ground. The outside hind leg (beat one), is still touching the ground, but is about to be lifted off.
3. Beat Three: The grounding phase of the inside foreleg. The outside hind leg (beat one), is off the ground. The inside hind leg and outside foreleg are still touching the ground, but are about to be lifted up.
4. The inside hindleg and outside foreleg (beat two) are lifted off the ground. The inside foreleg is the only foot supporting the horse's weight.
5. The inside foreleg is lifted off the ground.
6. Suspension: The horse has all four legs off the ground.

The faster the horse is moving, the longer is the time of the phase of suspension relative to the time of the three beats.

The lope and gallop are related gaits, as the rider simply asks the horse to gallop from the canter by allowing it to lengthen its stride until it is four-beat, rather than three-beat. When the stride is sufficiently lengthened, the diagonal pair of beat two breaks, resulting in the inside hind striking first, before the outside fore. The horse is able to easily move in and out of the gallop using the canter.

The trot is a two beat diagonal gait of the horse where the diagonal pairs of legs move forward at the same time. There is a moment of suspension between each beat.

Monday, August 23, 2010

What is a Mathematical Model?

Recently I saw a question on Answer.com that was not answered, so I took the opportunity to provide a response. First, not all models are mathematical. Modeling in general is to pretend that one deals with a real thing while really working with an imitation. In operations research the imitation is a computer model of the simulated reality. A flight simulator on a PC is also a computer model of some aspects of the flight: it shows on the screen the controls and what the "pilot" (the youngster who operates it) is supposed to see from the "cockpit" (his armchair).

In order to understand what it means to model a phenomena or process, we must first understand the term "model" and understand its limitation. A model is a physical, mathematical, or otherwise logical representation of a system, entity, phenomenon, or process . A model can also be thought of as an abstraction of the real world, or an approximation of it. If you think about the problem of modeling a human being, or just the mind of a human, you can immediately see the limitations of modeling. We can use the term "system" to encompass systems, entities, phenomenon, or process. Since a modeling is a representation, abstraction, or approximation of the "system" being modeled, we must understand that it is not an "exact" representation, i.e., we can't model every aspect of the system. First, we don't know everything we need to know in order to model the system. We may not be able to define a process of the system with mathematical precision, or with heuristic algorithms, and many of the processes may not appear logical. Second, even if we were to know everything about the system, we may not have enough computing power to model every process, at least for complex systems, e.g., a human being, the earth's ecosystem, etc.

Yet with their limitations, models are a good way to gain understanding of how a system operates. George E.P. Box said, "All models are wrong; some models are useful." They are wrong in that there is not a one-to-one mapping form the real system to the model; they are useful in that we can use them to understand the system, or at least certain aspects of the system. Even though we often use models to predict behavior, this is a dangerous process, and we must do it with caution.

There are many types of models that one can use when trying to represent a system. These can be divided into several classes, and for simplicity we will consider two classes: physical models and symbolic models . Physical models include mock-up models (e.g., a vehicle mock-up), scale models (e.g., a 1:48 scale aircraft model), Iconic model, natural model, or a fashion model (which represent what we all want to look like).
Symbolic models include narrative models, graphical models, tabular models, software models, and mathematical models. These models are not necessarily mutually exclusive. For example a tabular model might contain data derived from a mathematical model, or a mathematical model may be embedded in software code.

So, a mathematical model is a symbolic model, or a symbolic representation or imitation of a real system or phenomenon. An example of a model is the equation for a line (a liner model) y = mx + b. A more complicate mathematical model is a model model is the waiting time for the drive through window at McDonalds at lunchtime (I will not confuse you with the mathematical formula). We do have models that cover all times during the day (at the drive through), but the solutions to these models may not be derived, "mathematically." We use numeric approximations, heuristic models (or algorithms) and simulations to solve these.

Selected mathematical modeling references:

1. http://en.wikipedia.org/wiki/Mathematical_model
2. http://www.math.montana.edu/frankw/ccp/modeling/topic.htm
3. http://www.meaningfulmath.org/modeling
4. http://www.learn.motion.com/products/modeling/index.html
5. http://www.stt.msu.edu/~mcubed/modeling.html
6. http://www.blurb.com/bookstore/detail/1461238
7. http://www.mat.univie.ac.at/~neum/model.html
8. http://www.math.colostate.edu/~pauld/M331/

Friday, August 20, 2010

You Can't Simulate Everything

Things you cannot simulate include: (1) the effect of coffee and chocolate on human behavior, (2) what my youngest daughter will say next, (3) whether or not I will sleep tonight, and (4) what happens when 180 children meet together, unsupervised. Well, maybe chaos theory can help us with #4.

Sunday, August 15, 2010

Simulation Validation Using Test Data

In simulation, real world data is not always available for validation, or anchoring. Often we must rely on the results of live tests, e.g., flight tests. In the execution of "Results" Validation, we must consider the relationship between the test and M&S environments.

While test is probably the highest fidelity representation of the prototype system, limitations in the test program usually will not allow exercise of the system in its true production configuration or through out its complete envelope. The portion of production environment exercised by the test is depicted in the circles in the Venn diagram in Figure 1 (proportions are for illustration only - no scale is intended).

From Figure 1 we see that some functionality (data) of the test are representative of the production system while others are not. Now consider a simulation of both the test (by a HWIL simulator) and of the production system as shown in the rectangles of Figure 1. Simulation of each environment/configuration of is not an exact representation. The differences between the test and HWIL simulation as well as the difference between the production system and the system simulation must be accounted for.

Figure 1: Simulation of the Test and Production Systems

Two points are worth noting from the above figure. First, while the test may be a higher fidelity representation of the prototype, only some of the functionality applies to the production system. Secondly, the simulation of the system/test is not exact. It does not cover all of the behaviors and also may provide outputs that would not be allowed by the actual configurations. Therefore, care must be taken in the selection of the data that will be used for Results Validation.
The Results Validation Process must define the “accuracy” of the data and determine which data can be used for the purpose of ensuring the fidelity of the M&S. In general, the following assumptions are made for the Results Validation process:

1. The tests are simulations of the prototype (as is) system.

2. The test is the most accurate representation of the prototype system.

3. Once validated by test, the HWIL simulation is the next most accurate simulation of the prototype system.

4. Once validated, the digital simulation follows the HWIL simulator as a depiction of the prototype system.

5. Once validated, the digital simulation is the best representation of the production system in its’ intended environment.

Thursday, August 12, 2010

Toast to the Flag


What does this have to do with simulation? In one sense, it has nothing to do with simulation. In another sense it has everything to do with it, at least for me. Now, I may die a POOR man, but I will also die as a man of integrity and honor. For me, the flag represents an ideal America and the ideas of our founding fathers (since it is a representation, I suppose it is a model). I don't always like what our country or its leaders do. I don't always like the direction in which we're heading. But I do love the ideal America, and this is what the flag really represents.

I served in the military for 24 yours to protect the flag (not the cloth--the idea). I hope that as you read, you'll consider your own flag, whether it be that of India, Indonesia, China, Russia, or South Africa. The flag is why I do simulation.

I delve into simulation to find the means for a safer and more secure country, an economically stable country, an environmentally friendly country, and even a better educated country. I believe that I am serving the idea of freedom and people of this country, not so much its leaders. If you're reading this from India, Argentina or another country, I hope you'll have the same heart for your country. With simulation we can experiment with ways to have a safer world, better communication, etc.

Finally, here is a Toast to the Flag:

Here’s to the red of it —
There’s not a thread of it,
No, nor a shred of it
In all the spread of it
From foot to head.
But heroes bled for it,
Faced steel and lead for it,
Precious blood shed for it,
Bathing it red!

Here’s to the white of it —
Thrilled by the sight of it,
Who knows the right of it
But feels the might of it
Through day and night?
Womanhood’s care for it
Made manhood dare for it,
Purity’s prayer for it
Keeps it so white!

Here’s to the blue of it —
Beauteous view of it,
Heavenly hue of it,
Star-spangled dew of it
Constant and true;
Diadems gleam for it,
States stand supreme for it,
Liberty’s beam for it
Brightens the blue!

Here’s to the whole of it —
Star, stripes and pole of it,
Body and soul of it,
O, and the roll of it,
Sun shining through;
Hearts in accord for it
Swear by the sword for it,
Thanking the Lord for it,
Red, White and Blue!

Tuesday, August 10, 2010

Simulation versus Reality

In my line of work, there is often a management expectation that simulation is a perfect reflection of reality. That is, there is a one-to-one correspondence between everything (e.g., variables) that make up reality and the simulation. In "reality" (pun intended), we merely chose those variables that scientific study has revealed as being the most important (or most sensitive to perturbations), and "ignore" other factors.

In a perfect simulation world (unlimited resources), we might not do this. But in "real" simulation, there is a trade-space for how much you can have, for how much your willing to pay, and for how much time you have to build the simulation (e.g., performance, cost and schedule). In complex simulations, we may not know all of the variables, so "knowledge" may be part of the trade-space as well. Managers seem to understand trade-space in the holistic project management realm, but sometimes fail to see its application when simulation is part of the project.

In simulation, bigger (e.g., more variables) is not always better. If we aim for higher fidelity on a subset of variables, we often get better results. All models of reality are inadequate, if one expects perfect correspondence with reality. However, "good-enough" models (and simulations of them) are useful.

Saturday, August 7, 2010

Using ExtendSim8


Imagine That, Inc. has released ExtendSim 8. I am writing a discrete event simulation textbook using this simulation tool. The latest version of the tool does not include the old discrete event library or the manufacturing library like version 6. However, it does support these older libraries. The Item library replaced the old Discrete Event library. If you understand the modeling blocks, like the Workstation or Queue, you can still build the same kinds of discrete event models that you could with version 6. In some cases ExtendSim 8 is easier and more flexible, if you have a deep understanding of discrete event simulation. I still find that Arena Simulation is more powerful and logical for discrete event simulation, but for the price ExtendSim 8 is a very good tool. Plus you can build models that are not discrete event, or have sub-processes that are not discrete.

Thus far, I have built a basic M/M/1 queue model for experimentation with experimental design, multirun analysis, batch means, warm-up period issues, and auto-correlation issues. ExtendSim 8 has the proper set of tools for dealing with these issues. This is a good way to validate your simulation model and your understanding of discrete event simulation, since we already know the analytical solution of an M/M/1 queue.

I have also built a hierarchical model of a bank lobby with multiple transactions, balking, animation, etc. that ExtendSim 8 handles quite well. A manufacturing model of circuit cards with multiple queues and processes was straight forward. The most challenging problem was a transportation system involving truck delivering packages to a warehouse, workers unloading packages, moving packages to a holding area, loading packages on delivery vans, and delivering packages. The most difficult part was working with the constraints of the Limited version of ExtendSim 8 (no more than 75 building blocks in a model), but this really forced me to think about the problem and make simplifying assumptions.

By the way, you can try the Limited version for $100.00 (download only) at http://www.extendsim.com/ (available for PC and MAC). ExtendSim is a registered trademark.

Look for my book "Discrete Event Simulation using ExtendSim 8" in September 2010.

Thursday, August 5, 2010

Praire Rattlesnake Experiments


Today, I was thinking about modeling a direct fire engagement between a prairie rattlesnake and a .410 single-shot shotgun in order to perform simulation experiments on the possible results of the confrontation. No need, the rattlesnake showed up in my backyard, and I was able to conduct a live experiment. The results favored the .410 shotgun.

Photo taken after the completion of the experiment.

Tuesday, August 3, 2010

Agent-Based Modeling and Simulation


From a modeling and simulation perspective, one novel way to perform movement (or C2) is to employ a polyagent modeling construct to produce emergent planning behavior. A polyagent is a combination of a persistent agent (an avatar) supported by a swarm of transient agents (ghosts) that assist the avatar in generating and assessing alternative (probabilistic) futures. The ghosts in the model employ pheromone fields to signal, identify, and act on threats and opportunities relative to the goals, which are then reported back to the avatars for integration and decision-making. I did some work back in 2006 for the Army Space and Missile Defense Command using this kind of agent-based modeling. One outcome of this was a paper in the Proceedings of the 2006 OR Society Simulation Workshop entitled “An Agent-Based Simulation of Satellite Utility for the US Army Future Force.

An avatar (I have not seen the movie)[i] is a computer user's representation of himself/herself or alter ego, whether in the form of a three-dimensional model used in computer games, a two-dimensional icon (picture) used on Internet forums and other communities, or a text construct found on early systems such as multi user domains (MUDs). It is an “object” representing the embodiment of the user. Fn is the resultant attractive force exerted by neighbor n and Dist is the distance to the target if it is known.

An Agent Based Simulation (ABS) is a computer simulation of some agent based system. ABSs are used by all kinds of scientists to build models of emergent phenomena such as flocking behavior, epidemics, social dynamics, etc. ABS is also used heavily in visual effect, often to simulate crowds and epic battles.

Most computational modeling research describes systems in equilibrium or as moving between equilibria. Agent-based modeling, however, using simple rules, can result in far more complex and interesting behavior.

The three ideas central to agent-based models are social agents as objects, emergence, and complexity.

Agent-based models consist of dynamically interacting rule based agents. The systems within which they interact can create real world-like complexity. These agents are:
  • Intelligent and purposeful.
  • Situated in space and time.

They reside in networks and in lattice-like neighborhoods. The location of the agents and their responsive and purposeful behavior are encoded in algorithmic form in computer programs. The modeling process is best described as inductive. The modeler makes those assumptions thought most relevant to the situation at hand and then watches phenomena emerge from the agents' interactions. Sometimes that result is an equilibrium. Sometimes it is an emergent pattern. Sometimes, however, it is an unintelligible mangle.

In some ways, agent-based models complement traditional analytic methods. Where analytic methods enable humans to characterize the equilibria of a system, agent-based models allow the possibility of generating those equilibria. This generative contribution may be the most mainstream of the potential benefits of agent-based modeling. Agent-based models can explain the emergence of higher order patterns—network structures of terrorist organizations and the Internet, power law distributions in the sizes of traffic jams, wars, and stock market crashes, and social segregation that persists despite populations of tolerant people. Agent-based models also can be used to identify lever points, defined as moments in time in which interventions have extreme consequences, and to distinguish among types of path dependency.

Rather than focusing on stable states, the models consider a system's robustness—the ways that complex systems adapt to internal and external pressures so as to maintain their functionalities. The task of harnessing that complexity requires consideration of the agents themselves—their diversity, connectedness, and level of interactions.

Verification and Validation (V&V) has always been a challenge with agent-based simulation, due to the nature of the models behavior (generating rather that characterizing a system's equilibrium). A formal approach for V&V of all agent-based models is based on building a VOMAS (Virtual Overlay Multi-Agent System), a software engineering based approach, where a virtual overlay Multi-agent system is developed alongside the agent-based model. The agents in the Multi-Agent System are able to gather data by generation of logs as well as provide run-time validation and verification support by watch agents and also agents to check any violation of invariants at run-time. These are set by the Simulation Specialist with help from the SME (Subject Matter Expert). An example of using VOMAS for Verification and Validation of a Forest Fire simulation model is given in.[ii]

VOMAS provides a formal way of Validation and Verification. If you want to build a VOMAS, you need to start designing VOMAS agents along with the agents in the actual simulation preferably from the start. So, in essence, by the time your simulation model is complete, you essentially have one model which contains two models:
  • An Agent Based Model of the intended system
  • An Agent Based Model of the VOMAS

Stay tuned for more on agent-based modeling and simulation.
_____________________________________________________
[i] In Hinduism, Avatar or Avatāra refers to a deliberate descent of a deity from heaven to earth, and is mostly translated into English as "incarnation", but more accurately as "appearance" or "manifestation".

[ii] Muaz Niazi, Qasim Siddique, Amir Hussain and Mario Kolberg, Verification & Validation Of An Agent-Based Forest Fire Simulation Model, Proceedings of the Agent Directed Simulation Symposium 2010, as part of the ACM SCS Spring Simulation Multiconference, pp142-149, Orlando, FL, April 11-15, 2010