Passionate about Modelling & Simulation

Network Availability or Reliability Model in an ExtendSim Block

Earlier this year I attended an interesting Webinar/Masterclass presented by Anthony Nastasi of Imagine That! He  discussed a variety of  different methods used to model reliability in ExtendSim. One method he showed was to set up a kind of reliability graph. I thought it would be interesting to encode a Monte Carlo solution to the source-terminal availability problem in an ExtendSim custom block. I then extended the block to provide a reliability option and the result of my efforts is presented below. It is more a proof of concept that a properly finished product but you might find it interesting. For now I will concentrate on a brief explanation of how it works. When I have time I will document the code and give a post on the modelling details as well as MODL techniques used.

Download the model here NetworkModel or on the Downloads page. The availability model is shown in a simple test model in the diagram below which also shows the associated database and block dialog.

Network Availability Model

The Network Database

There are Networks, Nodes, Links and Distributions tables in the database with the natural relationships between tables. Note that each node has a distribution associated with reliability analysis and a plain probability value for use in source terminal availability analysis. When analysing a network the first node is treated as the source and the last node the terminal. Links may be unidirectional (1 for A -> B) or bidirectional (0 for A <-> B).


Running the Block Model in Off-Line Mode

First select the network to analyse. To run the Availability Model Off-Line decide on the sample size for the Monte Carlo analysis and then click on the associated button. On my first generation i7 desktop a sample size of ten million takes about 5 seconds for the first test network. Reliability analysis can be run from the Reliability Estimate button. Although the analysis method is different – one sample is the event of a single node changing state from up to down or vice-versa – run time only increases to about 7 seconds. Note that reliability analysis uses an internal event list to determine the next node to change state.

Running the Block On-Line

If run as part of a discrete event simulation model the block acts as a value block and supplies a value of 1 if a working path is available or 0 when it is not. If the availability option is selected pulling a value triggers a new sample. If reliability is selected then the block just reports the current state.



Continue Reading

Generation of MODL Database Access Constants

One for MODL coders only! I was recently building a model with a database and needed to refer to the contents of the database from custom blocks and equations. This seemed a good place for the use of a header file. However, it would have been tedious to code all the constants I needed by hand so I wrote a little utility block to automatically generate the required code. As it is general purpose I though someone out there may also find it useful.


Take a copy of any model with a database and add the block from the library you can download here CodeGen or on the downloads page. If you open the block dialog you are presented with four check boxes:

  1. I often keep a simple table for model parameters. Just two fields in each record. The first is a string name for the parameter and the second a value. Checking this option searches for a ModelParameters table and for each record, generates a Constant with its name based on the name field and its value is set the MODL DBAddress for the value field.
  2. The second check box causes a ModelState table to be treated in the same way.
  3. This option causes the generation of a full set of indices for all databases, tables and fields in your model.
  4. ExtendSim also uses database for internal purposes. Normally you will not be interested to generate indices for these so use the check box to ignore them.

To generate the header file just click on the button and a file save dialog is opened. Select the all file types option (*.*) and give your file a .h extension and directory. Hitting save causes the file to be generated. The results will be similar to this (first few lines shown):

CONSTANT P_MinimumSpeedDBAddr is 20002002000002;
CONSTANT P_MaximumSpeedDBAddr is 20002002000003;
CONSTANT P_DistanceDBAddr is 20002002000004;

CONSTANT S_ActiveServersDBAddr is 20003002000002;
CONSTANT S_ClientsInSystemDBAddr is 20003002000003;

CONSTANT D1_ExampleDatabase is 1;

CONSTANT D1T1_ModelParameters is 1;
CONSTANT D1T1F1_Name is 1;
CONSTANT D1T1F2_Value is 2;

The naming convention is rather cumbersome but it does avoid naming conflicts as well as being simple to decode. P_ is used as a parameter suffix, S_ is a model state suffix while D1 means database 1, D1T1 means database 1 table 1 and so on. The code is quite straightforward – I have not had time to document it but variable names should help if you want to modify it. As usual let me know if you have any suggestions.

Continue Reading

2-D Growth Model

This model is a stochastic 2-D cellular automata written in VBA that uses Excel 2010 conditional formatting to generate a map. An example map is shown below representing the the state after 100 generations. The grid is originally seeded with 1’s in random cells and the probability of a ‘birth’ in a cell is proportional to a function of the cell contents and its immediate neighbours.  The VBA code is unprotected and the code needed to implement the model is quite short (about 100 lines of code) although a few hundred more lines of code are required for the interface.  The model worksheet displays the map and the parameters sheet contains the model parameters and some result statistics.  A modal dialog box is used to set parameters. If this is closed the underlying sheets can be copied and pasted etc… To regenerate the dialog click on the ‘Run Population Model’ button in the Parameters sheet. Down load from download page or here GenerateClusteredLocations.

2-D Growth Map


Model Parameters

The model parameters can be changed through the dialog box that appears when the workbook is opened. The growth rule is based on the contents of the cell and the 8 adjacent cells. A center weighting is applied to the cell and outer weighting to the adjacent cells. Thus probability of a new item is given by:

(Cell Item Count x Center Weight + Total Items in Adjacent Cells x Outer Weight) / Maximum Weight

If the cell and all its neighbours are empty then a Minimum Weight value is used in the numerator. If the calculated value exceeds one then a probability of one is used.


2-D Growth Dialog

         Grid Size – The size of square grid used can be adjusted

Initial Population – The selected number of items is randomly assigned

Center Weight - Multiplier for center cell item count

         Outer Weight – Multiplier for total items in adjacent cells

Minimum Weight – Weight used if cell and its neighbours are empty

Maximum Weight – See above

Generations – Number of full model iterations

Max Items in Cell – Once this is reached no more items are added to cell

Buttons and check boxes should be self explanatory – just experiment.

Continue Reading

Markov Chain Model

This is the first in a series of posts illustrating the use of MODL  programming for ExtendSim model development. It uses an equation block to contain the MODL code. The model simulates the behaviour of a three state Markov chain. Inputs to the model are the state transition probability matrix and number of instances to simulate.


Three State Markov Chain Model

Before a brief look at the code it is worth making a few observations regarding the use of equation blocks:

  • There are limitations to what can be coded in equation blocks. In particular, there are no static arrays or sub procedures. Workarounds are possible (using header files or global arrays for example) but may be cumbersome and there are memory limitations.
  • This makes it difficult to generalise the model to arbitrary sized state spaces.
  • In this case we would recommend the development of a custom value block. We will provide such a solution in a future post. While there are a few additional concepts that need to be understood we believe the extra flexibility to be well worth the effort.


MODL Code for the equation block

A few points worth noting about this code:

  1. The Initialise block at the top of the code is executed once the first time the equation is invoked. This is controlled by the Initialise static variable which is itself set to zero in the input variables listbox at the top of the equation dialog.
  2. Use of variables prefixed or suffixed by S0, S1 or S2. These static and local variables are to count the number of instances in each state. It is not difficult to see how use of arrays would simplify generalisation here.
  3. The StartCount static variable is used to determine the number of instances for looping purposes.
  4. Note the use of global array functions to access the ‘MarkovTransitionMatrix’ global array.

The model can be downloaded here: Markov3State.



Continue Reading

Bounce Diagrams

This utility analyses the packets from a trace obtained from Wireshark or other packet analysers and displays a time based ‘bounce‘ diagram’. This utility uses VBA to automate the construction of the bounce diagram from a packet trace imported into excel. Columns in the packet trace may need to be modified to fit the column headers shown in the packets sheet. As with most of our macros they read data rows until a row is reached with a blank first cell. Note that packets are colour coded according to a list in the names sheet.


It is rather basic but does allow end points to be named, conversations to be selected and time intervals defined. Note that the VBA for this utility is not available – on inspection it did not meet our most basic quality standards. If the author no longer understands it … Still the functionality is quite handy!

Continue Reading

Network Planning Toolset

This Excel Add-In has a comprehensive set of capacity planning functions; Erlang-B, Erlang-C, Engset including inverse forms. Suitable for Call Center sizing and other purposes. It also has functions for building flow models using a few lines of VBA code. The diagram below should give those with a wide area network planning background an idea how this works.


Originally developed in Excel 1997(!) but should work in any later version. I recently added some basic source-terminal availability analysis and will include this version in a later post. There is thorough documentation so if it sounds interesting download and read. The Add-In code is password protected but that will not stop you using the functions on a spreadsheet or in VBA. Contact NETMOD Ltd if you need the source.

Continue Reading

Modelling and Simulation Questions

We will do our best to answer questions submitted in our forum. We can typically give guidance in the following areas:

  • Random number generation, arrival and departure processes
  • Confidence intervals
  • Algorithms e.g. priority queues, graphs…
  • Modelling approaches suitable for particular problems
Continue Reading


This spreadsheet includes a 2-D clustering model using the K-Means method. The results can be seen in the screen shot below.

Clustering Screen Shot

Clustering Screen Shot





Continue Reading