Suvichara

Simulation:Keep them simple, but no simpler…

Posted by Prashant Hegde on July 19, 2007

It is surprising that in the software industry, lot of managers believe that availability of tools can magically solve some of their pressing problems. They do not think about the competency needed to use the tool for solving those problems. They forget that – ‘fool with a tool is still a fool’!. This applies to many engineering tools, especially to modeling and simulation tools. Lot of organizations do think that these tools are a panacea. They invest heavily on these tools only to realize later that they have not made any progress!

One of the few things to be aware of simulations are – the results of simulation are only as good as the simulation model itself. One of the important things to be aware of is the correctness of input data used for the simulation. Put it another way – ‘garbage in, garbage out’!. The first thing to do while building a simulation model is to analyze the input data. Many times, data needs to collected from the real-world processes. These data are called are stochastic data. The data can be modeled as probability models. Once you collect data from the real-world processes, you need to come up with probability models for generating these data. There are many input analysis tools that give you the probability models and their parameters from the real-word or experimental data. The trick is to decide when you have enough data that can be fed to input data analysis tools! Once you have probability models for inputs, you can verify that they indeed have the same distribution as the real-world data by carrying out Goodness of Fit(GOF) test. Again, this is tricky. You need to know that you have enough data so that the test correctly tells you if they are drawn from the same distribution. Another way to verify this is – if after feeding the input data the simulation result should resemble the real-world process behavior. If not, you will have to suspect your input data. If no real-world data is available, then you can consult experts in the field about the correctness of your input data. Another factor that affects simulation output is the correctness of model itself.

There are so many input distributions possible: random data, uniform distribution, normal distribution, exponential distribution etc. One of the ways these plethora of distributions are handled is by using the Gamma distribution. Other distributions can be derived from this distribution as special cases.

It makes sense to keep the simulation model simple to start with. Once the basic model is running and the behavior is acceptable, start adding more and more details so that it is closer to the real-world process. The trick here is to model only the relevant information that affects the simulation output and omit irrelevant or less important details. The correctness of the simulation can be done via verification and validation. To quote Einstein – Keep the model simple, but no simpler. So, the philosophy here is – Seek simplicity Then distrust it. [Alfred North Whitehead].

Many simulation tools provide – hierarchical modeling capability. This feature allows the modeler to model the system at different levels of abstraction. The models themselves can act as basic modeling blocks for higher levels of abstraction. This feature not only makes models simpler to understand, but also makes them scalable and re-usable.

In many of the real-world problems we need to create models using many different paradigms for eg: continuous time, discrete time, discrete event etc. One of the few tools that allows ‘embedding’ of different modeling paradigms is Berkeley University’s: Ptolemy. OMnet++ is a popular open source network simulation tool. Visit here for a list of simulation tools.

Posted in Modeling-Simulation | 1 Comment »

We saw it. Yet, we din’t see..

Posted by Prashant Hegde on July 2, 2007

This is so true!. It happens to everyone of us. Sometimes, the world around us would have changed so much that we realize and wake up to this fact after a long time. One of the reasons for this is that – our beliefs, goals etc act as blinders and keep us moving in a particular direction without paying much attention to what is happening elsewhere. The other reason is because of the information overload. We can not spot and identify these patterns in this huge amount of data. Or, the trend may be too small a thing to get noticed and we ignore it as irrelevant.
The same thing happens to businesses also. They need to spot the trends early and capitalize on it. Many times they are so much obsessed with their strategies, tactics and new technologies that they don’t realize the change in current trends. There is little point in sharpening your saw, when your opponent is possessing a gun!. These kinds of surprises are seen many times in the history of wars, businesses( the Iridium project for e.g) etc. It is not easy to spot changes in the trends either. It requires an open mind and willingness to abandon the current path and pursue a new strategy. This is easier said than done. Businesses are so emotionally attached to their strategies, technologies that they don’t ’see it coming’!. Another reason could be because of the sunk cost and loss aversion biases. By the time they realize, it is too late. So, they must be ready to renunciate before it becomes too late.

Many times we do recognize that it is coming. However, we wish it may not really come. This is kind of wishful thinking. The kind of thinking that suits our needs, wishes rather than accepting the reality which is uncomfortable. We tend to search for, collect more information and interpret information that conforms to our beliefs and tend to avoid information that contradicts our beliefs. This is called – conformation bias. Psychologists say that this kind of thinking is hardwired in our brain!. So, it is very hard to escape from these biases. All we can do is to be on alert, always!!.

(I have taken the heading line from Robert Pirsig’s “Zen and the Art of Motorcycle Maintenence”. There is a similar shloka by Sankaracharya in ‘Bhajagovindam’ which says – “Pashyannapi na cha pashyati mudho..” which means- fools see, but don’t see!. However, Sankaracharya wrote this in a different context!).

Posted in Ramblings | 1 Comment »

Gaming Industry comes full circle…

Posted by Prashant Hegde on June 26, 2007

Nintendo is back at no 1 again. According to this article in CNN Money, which analyzes why Sony lost -

There are a number of lessons we can glean from this — not just for the future of videogame consoles, but the future of consumer electronics. Decades from now, PS3 vs. Wii will be remembered as a cautionary business tale: how pride, politics, and an overabundance of technology can blind you to the simple truth of what consumers want.”

While Sony chose to make its Play Station more powerful and more feature rich, Nintendo concentrated on usability and cost. As the article says -

“Why change something that is already installed in 200 million homes worldwide? Answer: because there are more people in those homes that don’t play games, and hundreds of millions more homes to win over”.

The article further comments on Sony’s and Microsoft’s strategy of adding more and more technology-

“You buy them for the games, but once inside your home, they take over your life. They become the brains of your TV, your entertainment center, even your main communications device with IP telephony and chat functions. They converge all your technological needs in one box. (Microsoft, at least, didn’t assume that we would only want to use its technology in this converged device; it allowed you to plug in your iPod to the Xbox 360.)”

While Nintendo’s strategy was -

“…. When you buy a videogame console, the company says, you want to play games. Period. A console is not a Swiss Army knife. It makes sense to squeeze more functionality into your cell phone because you carry that device around everywhere. When it comes to the interactive fun box in your living room, however, it makes sense to simply make that more fun. If you want a DVD player, you’ll buy a DVD player. “

While Sony and Microsoft sell their gaming consoles at a loss, Nintendo actually makes profit on the sales. Sony is paying for forgetting what the customer wants.

This is how it typically works. Initially, when products come onto the market, they all look alike. In order to differentiate their products, manufacturers add more features. It is these features that differentiates the products in the market and help gain market share. However, if you take this strategy too far, it back fires. But, the question is – ‘how to decide when to stop?’. It is not easy to decide when to stop. Sony, apparently, did not know where to stop.

In his book “Design of Everyday Things”, Donald Norman talks about “technology paradox”. He says products follow a ‘U’ shaped curve. When things are complex, a new technology helps to bring it down. However, once the complexity is brought down, more and more features are added which makes it complex again and the cycle repeats!..

Posted in Ramblings | 1 Comment »

UML Activity Diagrams 101

Posted by Prashant Hegde on June 23, 2007

One of the unique features offered by the Activity diagrams is – it makes possible to combine non-Object Oriented (referred to as OO) modeling with OO modeling. Most of the times than not, people use specialized non-OO libraries in their OO design. UML activity diagrams make modeling of non-OO library calls possible in their OO designs. Similarly, Activity diagrams can be quite useful for Business Process Modeling for enterprise modelers or for modeling the flow of information, control, energy etc for System Engineers. It can be used, for example, to graphically detail use cases. It can also be quite useful for project managers/system Engineers represent the project/product development process. People who are familiar with Petri nets, Data Flow, Control Flow Diagrams will find themselves at home with Activity Diagrams. Another important addition to Activity diagrams is the addition of parameter nodes (technically, they are object nodes) that allows the invoker to pass parameters to the model and receive output from the Activity. Activity diagrams can be invoked from other Activity diagrams thus making them reusable.

The activity model is defined with semantic variations, which means that the runtime behavior might vary from implementation to implementation and the modeler can choose the behavior that is appropriate. The basic constructs of Activity diagrams are – Action Nodes, Control Nodes (Decision nodes, Fork and Join, Initial Node, Finals Nodes) and Object nodes.

  • Action nodes represent behaviors, which can be – Activities, State machines or interaction diagrams. They consume control and data (referred to as tokens) and output control and/or data. Actions could be – create object, set object or invoke some behavior. Note that the actions can be represented as a function in procedural language like – C or as a method in OO languages, or as a class with behavior in OO languages. Actions are the only constructs in UML that can invoke operations on objects. Note that each action node may have more than one input (control and/or action). The action is triggered only when all the inputs are available. When the activity ends data/control is placed on the outgoing nodes (object node or control flow).
  • Control nodes are used for controlling data/control flow through the diagram based on decisions or provide parallel paths for data/control flow or terminating an activity.
    • An activity diagram can contain more than one start nodes. An activity will start at all these nodes simultaneously. So, it is better to have a single start node to avoid confusion.
    • Decision nodes help route flow to different paths in the diagram based on the evaluation of guard conditions placed on each path. Care should be taken not to have more than one guard condition evaluating to true at the same time. Another useful thing to remember is – guard conditions should not have any side effects. Decision nodes can be chained. Note also that decisions nodes can invoke other Activities to decide routing.
    • Merge Nodes are used to merge multiple flows. Just like the decision nodes merge nodes can be chained.
    • Fork Nodes split flows into more than one simultaneous flow. Data / Control are simply copied onto each path.
    • Join nodes synchronize multiple flows. Note that if there are multiple control tokens coming into the join nodes they will be merged into a single token. If there are both control and data tokens only data tokes are copied onto the outgoing flow. No control tokens are copied. Also, modelers should pay attention not to have any flow final nodes in one of the join paths, which would otherwise make the next action wait indefinitely if the flow is terminated. Like merge nodes join nodes can also be chained.
    • Flow final nodes receive control / data tokens and do nothing. Effectively, they end the flow in that path.
    • Final nodes end an activity when any token is received. This can be used instead of flow final as this node will terminate the entire activity including other concurrent paths.
  • Object nodes act as placeholders for data as it moves along the path. Object nodes can hold single token, multiple tokens, buffering, backup, central data store etc. The object nodes can optionally contain the state of the object. The object can also be a group of data. Object nodes can traverse the edge only when all the input-output pairs are ready. Central buffers can be used when it is necessary to allocate to token to different competing destinations.

Activities can be connected to other activities directly when they carry control or through object nodes when they carry data. As mentioned above Actions start as soon as all the inputs are available. However, streaming parameters are exceptions to this rule. Streaming parameters can accept and output parameters while an action is executing (at least one input must arrive for the action to begin). Apart from normal output parameters the action can also output exceptions as well indicating an exceptional condition. When an exception is output, other outputs are not defined. Note also that exception outputs cannot be streaming. It is also possible to group parameters (called Parameter Sets) such than exactly one of them accept or provide values. Constraints such as pre-conditions, post-conditions can be applied to actions, which can be specific to a particular invocation of a behavior or could apply to all invocations of that behavior. The other useful feature of Activity diagrams is the swim-lane notation. Swim lanes group activities. A swim lane for example could represent a department and its responsibilities or different hardware or different components or different classes or attributes etc.

For more information, interested readers may consult a series of 6 articles by Conrad Bock(Conrad Bock: UML 2 Activity and Action Models” )

Posted in Modeling-Simulation, Systems Engineering | Leave a Comment »

The Risk and Uncertainty debate…

Posted by Prashant Hegde on June 15, 2007

There is a lot of discussion about the differences between risk and uncertainty. There is no universal agreement on the differences between two terms and the debate is still on!

Quoting Frank Knight – “It will appear that a measurable uncertainty, or “risk” proper, as we shall use the term, is so far different from an unmeasurable one that it is not in effect an uncertainty at all. We … accordingly restrict the term “uncertainty” to cases of the non-quantitative type..”. This essentially means that risk can be quantified in terms of probabilities where as uncertainty is not. According to Knight, there are two types of probabilities – objective and subjective. A probability is called objective probability if any of the following conditions are true -

  • When there is symmetry in the information ( for eg: tossing a coin )
  • Statistical analysis of experimental data is possible

He considered other probability assessments subjective( or as ‘personal probability’ as some authors prefer to call it). He considered subjective probabilities as uncertainties and not as risks. As some critics noted, there may exist more than one symmetry in a given situation and hence the probabilities might differ from person to person. And, hence the first condition is really subjective. In the real world scenario, we rarely get enough experimental data to carry out statistical analysis on them and deduce probabilities from them. Hence, the the second condition is also very difficult to achieve in practice. Even if we have enough data on a given situation how are we sure that we have complete data and not ignored relevant data. So, we can say most of the times we only have subjective probabilities. So, we can not really make a distinction between risk and uncertainty. Other authors have the view point that calculation of probabilities is inherently subjective and advise that expert opinions should be considered while calculating probabilities. So, this process is more like a Bayesian than a frequentest approach.

Even though there are other theories to distinguish between the two, no theory is able to explain the differences between the two terms convincingly. So, most people use them interchangingly. Many people use the risk in a negative sense( i.e as a threat) and treat uncertainty as both positive ( i.e opportunity ) and negative. PMBOK, for example, uses the term risk in both the positive and negative sense. Design For Six Sigma (DFSS) considers risk in the negative sense. It uses Risk Priority Numbers(RPNs) to quantify risks. System Safety Engineering carries out Hazard analysis to identify risks within the system to be built so that they can be managed safely. Some authors advise using options theory to deal with uncertainties. They advise building flexible systems so that favorable events can be exploited when they arise and the impact of unfavorable events are minimized.

Posted in Ramblings | Leave a Comment »

Statecharts and tools…

Posted by Prashant Hegde on June 11, 2007

Statechart(also called state machine) diagrams are one of the most powerful modeling constructs available to modelers. It is used to model reactive systems. By reactive, we mean, that part of the system that responds to external events or operations.

In UML, classes can have statecharts as part of their behavior. Modeling the reactive behavior using Statecharts makes designs more manageable, easy to debug, easy to maintain and, of course, more understandable. The CASE tools depend heavily on Statecharts for the code generation.

Rhapsody is one of the UML modeling tools that has provided extensive Statechart modeling support for modeling embedded systems. Rhapsody also provides an OS independent Object Execution Framework(OXF) implemented in C++ that provides base classes, an event loop for dispatching events, event queues for storing events etc. The modeler can concentrate on modeling the solution and not worry about its implementation. Rhapsody generates all the code for you!. There is also a another framework called IDF that implements the Statemachine in C and is suitable for systems where memory and performance are a concern. Rhapsody also provides animation support debugging state machine logic.

Apart from UML tools, there are other tools that support Statechart modeling. I am listing some of them here. Telelogic’s Statemate is a very popular too for modeling embedded systems. Mathworks’  Stateflow is another. Berkeley University’s Ptolemy is a popular simulation tool that supports Statechart modeling.

Quantum Leaps is a company that provides a framework for implementing Statecharts that is suitable for embedded systems. Boost is an open source C++ template library that provides a Statechart library.

Powered by ScribeFire.

Posted in Modeling-Simulation | Leave a Comment »

Implementing your own Domain Specific Language(DSL)

Posted by Prashant Hegde on June 7, 2007

DSLs are gaining importance again. Thanks to UML. UML did not live up to its promise. The problem with UML is- it is too generic and very vast. The semantics of UML is also not clearly defined. The vastness deterred people from learning it and lack of precise semantics made people frustrated. Lots of time and money has been spent in the industry on learning UML, UML tools. But, the usefulness of these tools still remains a question for many.

MDA(Model Driven Architecture) gave the promise that people just need to do only modeling and write no code. Code is generated from the model. People can ‘execute’ models, ‘debug’ models and ‘deploy’ models. Even though the concept looks good, there are lots of practical limitations in implementing this concept. There is hardly any tool in the market that fully implements MDA. One of the ways people build executable models today is by ‘writing’ code within models!

Realizing this, Microsoft started promoting DSLs. It is one of the important tools that is part of their Software Factory concept. DSLs are custom languages for a domain. For ex: regular expressions, which you might me familiar with, is a DSL that is used for matching patterns within a given text etc. Microsoft developed DSL Tools SDK that allows users develop their own DSLs. This DSL SDK is now part of Visual Studio. Apart from Visual Studio, you can use various open source tools for building your own DSL. Vanderbilt university’s – Generic Modeling Environment(GME) is a popular meta-modeling tool that can be used for building DSLs. Honeywell’s DoME is another free meta-modeling tool. Eclipse has limited support for building DSLs. MetaEdit+ is a popular commercial DSL tool from Metacase. You can also build text based DSLs based on Lex, Yacc, ANTLR etc.

Building your own DSL(s) is less complex, easy to learn and, also, better auto source-code generation is possible from them. You can build your own Language Workbenches( see article from Martin Fowler on this) using these DSLs for example…

Posted in Modeling-Simulation | 2 Comments »

Traveler’s Dilemma and Behavioral Economics

Posted by Prashant Hegde on June 6, 2007

Kaushik Basu has devised an interesting game called Traveler’s Dilemma. The problem is stated as below:

Lucy and Pete, returning from a remote Pacific island, find that the airline has damaged the
identical antiques that each had purchased. An airline manager says that he is happy to
compensate them but is handicapped by being clueless about the value of these strange
objects. Simply asking the travelers for the price is hopeless, he figures, for they will inflate it.
Instead he devises a more complicated scheme. He asks each of them to write down the price
of the antique as any dollar integer between 2 and 100 without conferring together. If both
write the same number, he will take that to be the true price, and he will pay each of them that
amount. But if they write different numbers, he will assume that the lower one is the actual
price and that the person writing the higher number is cheating. In that case, he will pay both
of them the lower number along with a bonus and a penalty–the person who wrote the lower
number will get $2 more as a reward for honesty and the one who wrote the higher number
will get $2 less as a punishment. For instance, if Lucy writes 46 and Pete writes 100, Lucy will
get $48 and Pete will get $44.
What numbers will Lucy and Pete write? What number would you write?

According to the game theory – the payoffs for both Lucy and Pete is – ( 2,2). And this is the Nash equilibrium for the problem at hand. Equilibrium happens at (2,2) if you go by the assumptions of classical economics assumptions – people act rationally and people are selfish and act to maximize their gains irrespective of others. Assume Lucy thinks she can make $100 by telling the price as 100. Soon she realizes she can make $101 by telling the price as 99. Realizing the Pete might play the same trick, she decides she will say 98 etc so on so forth till they reach $2 where the equilibrium happens.

Basu says the – the Nash Equilibrium is reached if the game is played rationally and questions the rationality of players in the real-world.

I agree with him in that people get maximum pay off in this game if they acted irrationally. That is how it works in the real-world!. Often(if not always!), people behave irrationally. That is the question behavioral economics tends to question. It has recognized that there are various cognitive biases that are at play when people make choices. And, most often than not these choices are irrational. If you ask me, if the price of the item in question is $42, then in the real-world you will at least get $42 ( or 40?) or more if people are loss averse. However, by applying the second principle, they can maximize their payoff by quoting a value near 100.

Scott Adams, the creator of Dilbert says that people are irrational. They make choices first and then try to rationalize it by giving various reasons. Even psychologists say humans are irrational. Behavioral economics is trying to explain the economic behavior of people in this light…

Posted in Ramblings | Leave a Comment »

Presentations..

Posted by Prashant Hegde on June 2, 2007

I don’t know if this has happened to you, it has certainly happened to me.You are attending a presentation. The speaker is giving you information on a new product or a new technology, or on some system or some marketing information. The presentation is great with lots of charts, tables, pictures etc. The presenter has nicely divided the presentation under various headings each explaining different aspects of the subject. If you are already familiar with the subject, you do not have much problem following it. If the topic is new, you start paying more attention. After few slides, you start feeling little uneasy. You look at others – everyone seems to follow the subject without any problem. So, you hold back yourself from asking questions thinking that others might think you are stupid. As the presenter moves from one aspect to another, you have difficulty in linking them. You try to use your imagination and try to create the linkages between various entities being explained. Then, suddenly, one brave soul starts asking questions to the presenter. Ah..!, you suddenly realize that others are also sailing in the same boat as you. After few more questions, some of the aspects become clear. As you start asking more and more questions, the presenter starts feeling little uneasy because he is running out of time. So, he tells you that he does not have much time left and skims through rest of the presentation. You use your extra-ordinary imagination and try to make sense of the entire presentation. You assume many things that are not explicitly spelled out by the presenter. There is a high probability that your assumptions are wrong!. As one of my managers said, assume means – ASS-U-ME!.

Assume for a moment that you have not seen a car in your entire life. And the presenter is explaining about various parts of the car – the steering, wheels, brakes, accelerator etc. He gives detailed specifications for each of these parts. So, what happens after the presentation is, even though you have understood various parts of the car, you are not sure how the action of the steering is ultimately connected to wheels. How the engine is connected to other parts of the car etc. What is missing from the presentation is – interconnections( i,e relationships ) between different entities.

I should admit here that I have done the same mistake before. We tend to get into details when it is not needed and pay little attention to linking the concepts together.This is especially true if the audience is new to the subject being explained. If you are presenting to management for funding, you need to present detailed data. But, for a general audience these details are unnecessary. I think the key is to remember – find out who the target audience is and present the concept keeping them in mind.

Powered by ScribeFire.

Posted in Ramblings | Leave a Comment »

Posted by Prashant Hegde on May 31, 2007

Transactive Memory

The
term coined by Daniel Wegner simply means – individuals can act as
extended memory to one another. That simply means that you need not
know something that you know that your wife or father knows. This is
described in detail in Malcom Gladwell’s “The tipping point”. A closely
knit team is more efficient in remembering things than individual team
members. This has a positive effect on how the team performs. May be
this explains the efficiency of Agile teams who rely heavily on communication among the team members. Gladwell also talks about effect
the magic number 150 has on organizations. He cites the case of
Gore Associates and their high efficiency. He also talks about how “peer
pressure” ( rather than dead-line pressures or pressure from
supervisors) pushes people perform better.

This also brings
forth the Japanese working style. Kenichi Ohmae describes in his book -
“The mind of the strategist”, about how the Japanese organizations are
structured. He talks about the how people work closely within/across
teams. According to him, in Japan, children are taught how to mix with others
and work in a group at school. This is the first lesson they learn at
school before anything else!. Does this explain Japanese efficiency?

Powered by ScribeFire.

Posted in Ramblings | 1 Comment »