WeDiG Sim - Weighted Directed Graph Simulator, the definitions
By: Reza Shamsaee
WeDiG Sim simulates a general model of complex systems that is called WeDiG model, which is submitted to the JASSS. WeDiG model have been tried deliberately to be similar to what (Barabási 1999) has been presented and it is called BA model. Moreover, the model has two mechanisms to create the scale-free nature of real networks: growth and preferential attachment, similar to the BA. Growth refers to continually adding of new nodes that causes increasing nature of the networks such as the World Wide Web. The preferential attachment describes the probability of establishing a connection to/from an individual. The definition of these mechanisms can be found in the related paper.
The WeDiG simulator’s has been developed under Visual Studio 2008, C++/CLI. WeDiG Sim is implemented to simulate the abstract configuration of complex systems. Normally, the complex systems have been visited, where multiple individuals interacts one another and have different impact on each other. Social networks, neural networks, transportation networks, and … are some important examples in this domain. Although, the main scope of WeDiG model is the weighted directed complex systems, it can handle the situations of un-weightedness, un-directedness, or both. Due to the abstract definition of complex systems as a graph or a network, throughout of this context we use node, individual, and agent interchangeably. Also communication, connection, and edge have been used in a similar meaning.
Prerequisites for WeDiG Sim:
I have not found any limitation to run or compile the code. However, WeDiG Sim has been developed under Visual Studio 2008, C++/CLI (64bit) and windows 7. Its analyzing parts uses from “Ms Chart Control 22.214.171.124”, to use from this application and its source code, maybe you found to need some extra files that can be downloads from Microsoft site. At most you will need to install following files first:
“dotnetfx35”, “MSChart_VisualStudioAddOn”, and “MSChart“.
Starting the WeDiG Sim and its possible Settings:
To use WeDiG Sim, one should decide about the system settings, first. If your desired number of interacted individuals in the simulated complex system is small and you don’t want to perform the simulation repeatedly, it can be better to hold all the simulation process in the memory. So in the application, (Create WeDiG / Totally In Memory) gives you the best option and creates whole data structures in the memory and after the creation, they will be logged into (wdg) format.
As the WeDiG model uses the preferential attachment mechanism to identify the proper individuals to be communicated with/from. And the preferential attachment describes the probability of establishing a connection to/from a node. The whole created system has a stochastic configuration. Thus, to identify a pattern in the configuration of a simulated system, many simulation processes should be performed. The best choice to identify the pattern within a system setting or to increase the number of individuals in a system is (Create WeDiG / Partially In Memory). This option logs the simulated system in (wdgp) format.
Simply talking, this option creates the whole needed structure, in a partial approach. Although, the details will be lost, the aggregated information such as final I/O edges and their weights will be monitored. Moreover, two individuals, i-th and j-th, will be set to be traced through the evolving complex system.
(N) - The number of nodes. It shows the population size of a complex system. Be careful of what you select, the greater number of N (>100,000), the slower computer system. (Text Box)
(m0)- The initial individuals. The network growth starts from a small number of initial individuals (m0>0). (Text Box)
(m)- The number of OUTPUTS per a new node. The (m) outgoing edges come out from the newly introduced individual and link it to the previous (m) destinations where they already exist in the network and can be picked repeatedly (m ≤m0). (Text Box)
(n)- The number of INPUTS per a new node. The (n) ingoing edges go into the new node and connect the earlier (n) starting individuals where they currently exist in the network. They can be selected repeatedly (n≤m0). (Text Box)
(W_out)- Total Weight of OUTPUTS per a new node. The new individual is permitted to have (Wout) as its total output weight for its outgoing communications. For the simulation purposes of a real system, it is the expected output weight of the system’s individuals. (Text Box)
(W_in)- Total Weight of INPUTS per a new node. The newcomer individual is permitted to have (Win) as its total input weight for its ingoing communications. To simulate a real system, (Win) is the expected input weight of the system’s individuals. (Text Box)
(i-thi Node to Log) – The first individual should be set to be traced through the evolving complex system. This option exists for the partial simulation and monitors the individual through the time. (i>m0). (Text Box)
(j-thi Node to Log) – The second individual should be set to be traced through the evolving complex system. This option exists for the partial simulation and monitors the individual through the time (j>m0). (Text Box)
(P0 for creating (effected) ) - The effected input preferential attachments of all initial (m0) nodes are assumed and it is illustrated by P0 or ∏(Izero). It describes the attraction of an individual with no input, to be selected as a destination of a communication from a newcomer one. (Text Box)
(Automatic P0) - This option makes the program to choose ∏(Izero) automatically. (Radio Button)
(Manual P0) - This option makes the program to get ∏(Izero) manually. (Radio Button)
(Enter Path …) – You should choose your desired path and name file to store your simulated system’s results. The application will use it as the log file. (Text Box)
(Repeat the creation with current settings)- This option is false by default. If you make it true, the program will create some threads for current WeDiG Sim. The number of threads will be equal to the “Number of Times” This option helps you to use from all processing power of your computer to evaluate a configuration pattern of the complex systems with a special setting. (Check Box)
(Number of Times) – The option is one (1) by default. It tells the WeDiG Sim that how many times you would like to perform the simulation. For greater values than one, the current number of simulation will be added to the selected name of log file to prevent them to be overwritten. (Text Box)
Analyzing the logged systems and its important control’s Settings:
To analyze the simulation results, there are four choices.
1- (Analyze WeDiG’s Logs… / Totally In Memory): It gives you the capability to analyze those systems that have been logged under (wdg) format. The format is related to those systems that have created whole data structures in the memory.
2- (Analyze WeDiG’s Logs… / Partially In Memory /Single Log File): By this option, one partially created system that have been logged under (wdgp) format, can be analyzed singularly.
3-(Analyze WeDiG’s Logs… / Partially In Memory /Multi-Log Files/One By One Analysis (Gradually)): This option gives you the ability to analyze multiple partially created systems that have been logged under (wdgp) format. The logged files can be added to the group chart one by one. Although each system can be analyzed in detail separately, the general trend of all simulated systems is visualized.
4-(Analyze WeDiG’s Logs… / Partially In Memory /Multi-Log Files/Batch Analysis): This option gives you the capacity to analyze multiple partially created systems that have been logged under (wdgp) format. The logged files will be added to the group chart together, immediately. It is beneficial for the numerous simulations to be visualized and analyzed.
(Y=P(I)----X=I) - This option selects “the probability density function of input weights” as the type of analysis. It makes X-axis (horizontal) will be the input weight, and the vertical axis will be probability of visiting a special input weight. The input weight distribution will be visible by the chart. (Radio Button)
(Y=P(I).Beta/(W.Beta)^(1/Beta)----X=I) - This is scaled version of the input weight distribution. It makes X-axis (horizontal) will be the input weight, and the vertical axis will be scaled values of the probability of visiting a special input weight. This type of analysis is similar to (Albert 2002; Barabási 1999). (Radio Button)
(Y=I(t)----X=t) - This option selects “the input weight’s time evaluation” as the type of analysis. And the input weight’s time evaluation region associated with i-th node will be visualized. The horizontal axis shows the time, the vertical axis demonstrates the input weight of i-th individual of the simulated system. (Radio Button)
(Enter time’s index i…) - The i-th individual that has been entered to the simulated system. For example, if the initial individuals of a system is five (m0=5), 10-th node of system means 5-th individual that will be added after starting ( ti=5). You are not permitted to select any values less than the initial nodes (i-th individual>m0). (Text Box)
(Read) - This button gives you some general information around the loaded logged system, such as N, m0,…(Button)
(Image Path) - This button gets a path and file name to save the snap shot of the visualized data. (Button)
(R) - it shows the sample Pearson correlation coefficient (=r). (Text Box)
(R^2) - It shows square of the correlation coefficient between the data and the predicted value (R2) (Text Box)
(MAE) - Mean Absolute Error between the data and the predicted value (Text Box)
(Max Error) - It shows Maximum Error between the data and the predicted value (Text Box)
(VAR) - The variation of the data from the predicted value, the Standard Deviation (STD) can be calculated by it - STD=SQRT(VAR) -(Text Box)
NOTE: The code is not optimum and has not passed through the software testing phases, so damages or instability in the system can be occurred.
Description about the Design:
As a description, for the developers, the WeDiG Sim has an simple object oriented design. The WDG class works as a server class that has a central role in WeDiG Sim. And the user communicates with WeDiG Sim through various windows forms. The forms are not only for the communication purposes but also they validate the data.
The WDG class contains some methods and data structures to serve the job. To capture the directedness and weightedness property of the simulate system, WDG class uses from adjacent matrix. There are two type of running, and the data will be stored in two ways. In (Create WeDiG / Totally In Memory) whole data will be stored in “array^ WDG;” that makes it easy to trace all event of system. InMEM_Create_Total_WDG()is a member function that is responsible to fill the container 2D array.
In this 2D array the elements on the main diagonal are all zero (WDG[i,i]=0) the element can communicate to/from the previously added individuals not with themselves. And the element on a row that are located in the lower triangle are those elements that have received communication from the newcomer. And those that are located on the upper triangle are sender of links and weights to the newly introduced individual. It size will reach to (N^2)
After the creation phase, looking into an i-th column of the WDG in the lower triangle one can see how the input weight of the i-th node has been evolved through the time. Similarly for the output evolution of a node, it can be followed within a row in the upper triangle. However it is a simple way of logging events in the system it will dramatically use memory (N^2)*sizeof(float).
To overcome the memory shortage, I establish another easy way. In this approach, the only needed structures in the memory are reduced to the logged nodes “array ^WDG_i, ^WDG_j;” plus aggregated structure of incoming and outgoing weighs “array ^In_Sum, ^Out_Sum;”. Whole job in this case is done by InMEM_Create_Partial_WDG();
I hope this will be useful for those that want to go inside code. However, there are many comments in the source code that I expect you will find them helpful. Moreover, I welcome any question or critics around the code.
ALBERT, R., Barabási, A.-L. (2002). Statistical mechanics of complex networks. Reiews of Modern Physics, 74(1), 47-97.
BARABÁSI, A.-L., Albert, R. (1999). Emergence of scaling in random networks. Science, 286(5439), 509-512.
|Version||Submitter||First published||Last modified||Status|
|1.1.0||Reza Shamsaee||Tue May 15 16:57:18 2012||Sat Apr 27 20:18:53 2013||Published|
|1.0.0||Reza Shamsaee||Mon May 14 13:07:12 2012||Sat Apr 27 20:18:53 2013||Published|