This section is used to describe the pre-implementation design of the system, including design methods adopted and a structural overview.
The design is based on the object orientated approach, I decided to break the system into its smallest most basic components and construct the java simulator from the bottom up.
The diagram below breaks the system down into 8 main components. The infinitesimal generator and transition probability matrices components are sub-components of the standard matrix component, these are the most basic components of the system and are used to create and verify a matrix once the Markov chain has been specified. The probability distribution component will model the steady state probability, it is created by the main applet once the Markov matrix has been verified, along with the matrix, it is used to calculate and store the probability distribution and is used by the main applet to animate the chain.
The Markov chain component is used to allow the user to specify the Markov chain as it is being created. Each state and edge created is modelled in the Markov component using the Edge and State components.
The Markov chain drawing applet is the main running component of the system. When started, it initialises the Markov chain to blank, and then monitors the input, when edges are drawn, or states added it updates the Markov chain component. Each time a change is made, the applet will completely redraw the chain, so as to make sure it is up-to-date. Once the Markov chain is complete the user will make a selection to verify the chain, the applet will then create a Matrix from the Markov chain specified, and verify it is correct. If it is verified, the applet will then move to an analysing mode, still showing the initial Markov chain, then the user will make a selection as speed and type of animation to be shown, once selection has been made, the animation will begin. Using the probability distribution component and the matrix, the animation values are calculated and results given to the user in the selected animation method.
The above diagram is a basic outline of the system, with this I was able to construct classes from the various components and create a class diagram that would more accurately portray the implementation of the system in java.
To abide by the fundamental object oriented principles, classes are not allowed to directly access variables of other classes this means should I implement error checking at a later date, this is possible to do without affecting other classes. So there will have to be methods within every class to set or get every variable within that class, which other classes will use to gain access to those variables.
The classes representing the components above are as follows:
StandardMatrix class (standard matrix component)
To be a super-class to the Infinitesimal generator and transition probability matrix classes, needs create and store a blank matrix and its size, the matrix needs to store “double” values, and provide all necessary methods for other classes to:
DiscreteMatrix class (transition probability matrix component)
This will implement the transition probability matrix component above, it is a sub-class to the standard matrix class inheriting all the methods defined above. It is used to create and store a discrete matrix from a Markov chain and include methods to:
ContinuousMatrix class (infinitesimal generator matrix component)
This will implement the infinitesimal generator matrix component above, it is a sub-class to the standard matrix class inheriting all the methods defined above. It is used to create and store a continuous matrix from a Markov chain and include methods to:
· Discretize the matrix (i.e. return a discrete matrix that is used to model the Markov chain in the system).
ProbDist class (Probability
Distribution component)
This class will implement the probability Distribution component above. It is required to create and store a probability distribution for each state in the Markov chain, advance the distribution (in given steps) and store the size. It will include methods to:
· Initialize the distribution given a start state.
· Set the size of the distribution.
· Advance the distribution a given number of steps.
· Return a given distribution.
MarkovChain class (Markov Chain component)
This class will implement the Markov Chain component above. It will use the classes Edge and state below to create and store all aspects of the Markov chain specified on the applet and making them available so that they can be drawn on the applet It will include methods to:
Edge class (edge component)
This class will implement the edge component, it is used by the Markov chain to store the characteristics of edges between states. It will implement and store edge values (in the form of numerator, denominator) and labels. It will include methods to:
State class (state component)
This class will implement the state component, it is used by the Markov chain to store the characteristics of states. It will implement a and store state values (in the form of x and y co-ordinates) and labels. It will include methods to:
The class diagram for the above 7 classes is as follows:
Markov chain drawing applet
This last class is by far the real driving class of the simulation, it uses the above 7 classes and extends the default applet class to allow the user to specify and animate the Markov chain. The main functions of the class can be split into 3 sections: