In developing the calculate execution time function, I had to write the intermediate results(execution times of different algorithms with different data sets) into separate text files using commands in a batch file I created. These result file were created in "C:\AlgorithmAnalysisTool\Results" file.
Later I had to read these text files and get the execution times and create a tabular graph to present the results clearly as the final output of this function.
In reading the intermediate results from these text files, the order of readings was important because I put it to an array and later I write to the graph with the same order.
foreach (string fileName in Directory.GetFiles(@"C:\AlgorithmAnalysisTool\Results"))
{
numOfFilesR++;
}
string[] time = new string[numOfFilesR];
int timeIndex = 0;
// get your files (names)
string[] fileNames = Directory.GetFiles(@"C:\AlgorithmAnalysisTool\Results");
This Directory.GetFiles() does not read the files in the order of occurrence. That was the problem for me. So I sorted the files according to the creation time.
// Now read the creation time for each file
DateTime[] creationTimes = new DateTime[fileNames.Length];
for (int i = 0; i < fileNames.Length; i++)
creationTimes[i] = new FileInfo(fileNames[i]).CreationTime;
// sort it
Array.Sort(creationTimes, fileNames);
foreach (string file in fileNames)
{
StreamReader fileRes = new StreamReader(file);
time[timeIndex] = fileRes.ReadLine(); //taking the execution times
fileRes.Close();
timeIndex++;
}
After sorting the file names from the creation times I read the execution times which is inside these files and put it to the array 'time[]'.
So, later I take the execution times from the time[] and write to a text file called "FinalResult" as a tabular graph.
Sunday, September 29, 2013
Friday, September 27, 2013
Defining our own blocks in Blockly
Blockly is a web-based, graphical programming editor. Users can drag blocks together to build an application. No typing required. This tool was needed for our project to enable user to give his/her pseudo code as an input to the system.
You can visit blockly web site following this link.
https://code.google.com/p/blockly/
For this task we needed to define some new, simple blocks other than the existing blocks.
I used the block factory to define a new block. You can visit block factory following this link.
http://blockly-demo.appspot.com/static/apps/blockfactory/index.html
This is how it looks.
You can visit blockly web site following this link.
https://code.google.com/p/blockly/
For this task we needed to define some new, simple blocks other than the existing blocks.
I used the block factory to define a new block. You can visit block factory following this link.
http://blockly-demo.appspot.com/static/apps/blockfactory/index.html
This is how it looks.
There are pre-defined blocks in the panel to the left hand side under Input, Type, Title and Colour. You can drag and drop the matching blocks and develop the block you required. These blocks defines the look and feel of your final block. Here is an example of creating a simple for loop.
This is only half way completed. In the Preview area you can see the look of the block you are developing.
Here you can see the complete For block I have created. In this way you can develop any block you need.
Thursday, September 19, 2013
batch file
In this project I had to create a batch file, write commands for the batch file and execute it. Working with a batch file was a new thing for me.
I created the batch file like this..
System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\AlgorithmAnalysisTool\Commands.bat"); //creating the batch file
As you can see in this interface, user select the algorithm and the data set. i have to write to the batch file according to what user select.
file.WriteLine(@"@echo off");
for (int y = 0; y < width; y++)
{
for (int x = 0; x < height; x++)
{
file.WriteLine(@"C:\AlgorithmAnalysisTool\Setups\" + algo[x] + @".exe< " + @"C:\AlgorithmAnalysisTool\DataSets\" + data[y] + ".txt> " + @"C:\AlgorithmAnalysisTool\Results\res" + z + @".txt"); //writing to batch file
if (z <= size)
z++;
}
}
file.WriteLine("exit");
file.Close();
I store the user inputs in two arrays. So I take one by one using the for loop. Here I'm giving the data set as an input to the algorithm exe from "<" sign and directing the output to a text file using ">" sign.
Then what I had to do is to execute the batch file. For that I created a new process.
Process proc = new Process(); //creating a new process
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = @"C:\AlgorithmAnalysisTool\Commands.bat"; //passing the information to the new process
proc.Start();
proc.Close();
It was very easy with the batch file since I could write several commands to the batch file and execute all at once.
I created the batch file like this..
System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\AlgorithmAnalysisTool\Commands.bat"); //creating the batch file
As you can see in this interface, user select the algorithm and the data set. i have to write to the batch file according to what user select.
file.WriteLine(@"@echo off");
for (int y = 0; y < width; y++)
{
for (int x = 0; x < height; x++)
{
file.WriteLine(@"C:\AlgorithmAnalysisTool\Setups\" + algo[x] + @".exe< " + @"C:\AlgorithmAnalysisTool\DataSets\" + data[y] + ".txt> " + @"C:\AlgorithmAnalysisTool\Results\res" + z + @".txt"); //writing to batch file
if (z <= size)
z++;
}
}
file.WriteLine("exit");
file.Close();
I store the user inputs in two arrays. So I take one by one using the for loop. Here I'm giving the data set as an input to the algorithm exe from "<" sign and directing the output to a text file using ">" sign.
Then what I had to do is to execute the batch file. For that I created a new process.
Process proc = new Process(); //creating a new process
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = @"C:\AlgorithmAnalysisTool\Commands.bat"; //passing the information to the new process
proc.Start();
proc.Close();
It was very easy with the batch file since I could write several commands to the batch file and execute all at once.
Sunday, September 15, 2013
When doing a group project
For the SEP subject offered in the degree program in 3rd year at SLIIT, we had to form groups of 4 members. We formed a group including 2 girls and 2 boys. When choosing a project we talked and came to a one decision.
We got the same project we asked for which is the Algorithm Analysis Tool. Mr. Nuwan Kodagoda was our client as well as our supervisor.
Since we got a great guidance from our supervisor, we were able to understand our requirements clearly and give a good start to our project.
It is very important that you have a good communication with the client as well as the supervisor.
As a group you should understand each others capabilities and divide the work accordingly. When a member is having a problem in the task he/she got, others should give a hand to solve the problem. Then the real team spirit is there. In the Agile methodology, weekly stand up meeting are very helpful for this.
When preparing the related documents also, we divided the content among the group members. That was quit successful. So we completed the documents on time, and all got to know the content of the documents too rather than 1 or 2 doing the documentation.
All four members were committed to there work was an advantage. Each member was responsible for the quality of there part and testing as well. After doing testing individually we switched and completed the testing.
Whatever happens within the group it is important you keep it in the group, and have good relationship among all 4 members.
All these will take you to finish the project successfully and be a successful team.
We got the same project we asked for which is the Algorithm Analysis Tool. Mr. Nuwan Kodagoda was our client as well as our supervisor.
Since we got a great guidance from our supervisor, we were able to understand our requirements clearly and give a good start to our project.
It is very important that you have a good communication with the client as well as the supervisor.
As a group you should understand each others capabilities and divide the work accordingly. When a member is having a problem in the task he/she got, others should give a hand to solve the problem. Then the real team spirit is there. In the Agile methodology, weekly stand up meeting are very helpful for this.
When preparing the related documents also, we divided the content among the group members. That was quit successful. So we completed the documents on time, and all got to know the content of the documents too rather than 1 or 2 doing the documentation.
All four members were committed to there work was an advantage. Each member was responsible for the quality of there part and testing as well. After doing testing individually we switched and completed the testing.
Whatever happens within the group it is important you keep it in the group, and have good relationship among all 4 members.
All these will take you to finish the project successfully and be a successful team.
Subscribe to:
Comments (Atom)



