Working on discrete event simulator implemented using sorted list, for asunchronous coomunication. As I tried to put more than 10000 value in the loop. its giving me error of stack overflow exception. although I am not recursively calling any function plz help me its very important for me hanging for weeks for this...
using visaul C++ .Net - #include< math.h>
-
#include< time.h>
-
#include<List>
-
using namespace System;
-
using namespace System::Collections::Generic;
-
using namespace System::Linq;
-
double lambda,MuBro,MuSer,MuClient,Simtime;
-
-
double Min(double y,double z)
-
{
-
if(y<z)
-
return y;
-
else
-
return z;
-
}
-
-
double expntl(double x)
-
{
-
double z,y; /* Uniform random number from 0 to 1 */
-
-
/* Pull a uniform RV (0 < z < 1) */
-
do
-
{
-
-
z = ((double) rand() / RAND_MAX);
-
}
-
while ((z == 0) || (z == 1));
-
-
/* Inversion formula for exonential RV */
-
y=(-1/x) * log(z);
-
return y;
-
}
-
-
public ref class Example
-
{
-
public:
-
static void Main()
-
{
-
-
struct Analys
-
{
-
double TBa;
-
double TBss;
-
double TBsf;
-
double Client;
-
double WS;
-
double TSsf;
-
}Ana[20000];
-
-
Console::WriteLine("Please Enter the value of lambda-Arrival rate");
-
std::cin>>lambda;
-
Console::WriteLine("Please Enter the values for Mu for Client");
-
std::cin>>MuClient;
-
Console::WriteLine("Please Enter the values for Mu for broker");
-
std::cin>>MuBro;
-
Console::WriteLine("Please Enter the values for Mu for Server");
-
std::cin>>MuSer;
-
double NormWork[20000];
-
for(int i=0;i<20000;i++)
-
{
-
NormWork[i]=0.0;
-
}
-
double avgNormWork=0.0;
-
int Qbro=0,numDep=0,Qserver=0;
-
double Qsum=0.0,currtime=0.0;
-
SortedList<double, String^>^ slist = gcnew SortedList<double, String^>();
-
double TW=0.0, Wser=0.0, totalworkdone=0.0;
-
double value=0.1;
-
int cursor=0;
-
srand(clock());
-
double Wc=0.0;
-
double Time=0,TimDep=0.0;
-
double ClientWork=0.0;
-
Time=currtime+expntl(lambda);
-
slist->Add(Time,"ABro");
-
int id=0;
-
int no=0;
-
-
while(id<=20000)//*******this is loop accepting 10000 and giving right answer but wrong as 20000 is being put in it.
-
{
-
currtime=slist->Keys[cursor];
-
if(slist->Values[cursor]=="ABro")
-
{
-
Qbro=Qbro+1;
-
Wc=expntl(MuClient);
-
Ana[no].Client=Wc;
-
Ana[no].TBa=currtime;
-
no=no+1;
-
-
Time=currtime+expntl(lambda); //schedualing another arrival in the event queue
-
slist->Add(Time,"ABro");
-
Time=currtime+value;
-
slist->Add(Time,"SSBro");
-
}
-
else
-
if(slist->Values[cursor]=="SSBro")
-
{
-
TimDep=currtime+expntl(MuBro);
-
slist->Add(TimDep,"SFBroAser");
-
}
-
else
-
if(slist->Values[cursor]=="SFBroAser")
-
{
-
Qbro--;
-
Qserver= Qserver+1;
-
Time=currtime+value;
-
slist->Add(Time,"SSSer");
-
}
-
else
-
if(slist->Values[cursor]=="SSSer")
-
{
-
Wser=expntl(MuSer);
-
TimDep=currtime+Wser;
-
Ana[id].WS=Wser;
-
slist->Add(TimDep,"SFSer");
-
}
-
else
-
if(slist->Values[cursor]=="SFSer")
-
{
-
Qserver--;
-
Ana[id].TSsf=currtime;
-
id=id+1;
-
numDep++;
-
}
-
cursor=cursor+1;
-
}
-
-
for(int i=0; i<id; i++)
-
{
-
-
TW=Ana[i].TSsf-Ana[i].TBa;
-
ClientWork=Min(Ana[i].Client,TW);
-
NormWork[i]=(ClientWork+Ana[i].WS)/TW;
-
totalworkdone=totalworkdone+NormWork[i];
-
}
-
avgNormWork= totalworkdone/(id-1);
-
Console::WriteLine("No of messages arrived in the system were {0}", id);
-
Console::WriteLine("the average normalised work is {0}", avgNormWork);
-
Console::ReadLine();
-
-
}
-
};
-
-
int main(array<System::String ^> ^args)
-
{
-
Example::Main();
-
return 0;
-
}
1 1784 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Aguilar, James |
last post by:
Hello all,
To begin, yes, this -is- a homework assignment. However, it is for my
Algorithms class, and my instructor has given us explicit permission to use
"expert" groups like newsgroups, so...
|
by: hardieca |
last post by:
Hi,
I'm developing a program that analyzes all the webpages on my
webserver.
I've created one class, Filewalker(), with a function that returns the
paths of all ASP pages of interest as a...
|
by: Gorge Bush |
last post by:
Hi there,
all was going well with my first C# project until now as I am
getting a Stack Overflow exception. I haven't seen one of those since DOS
programming days and back then all you did was up...
|
by: David W. Walker |
last post by:
I am attempting to port a C code that runs OK on a number of Linux and Unix
machines to Windows XP using Visual Studio C++. I have set the program up as
a console application, but when I try to run...
|
by: Lee Greco |
last post by:
A third party vendor has provided me a C++ .Net DLL, a .lib and all necessary
..h files, as well as a sample C++ .NET app that uses the DLL. The sample app
needs the Stack Reserve Size set to...
|
by: jbix |
last post by:
We have a stack overflow happening. We are NOT doing any recusion. We do have an object being created in Global that is being handed the Context (which I assume is specific to the request thread). ...
|
by: Eric Webster |
last post by:
I have a fairly simple VB.Net program I'm developing that listens to data
coming over the internet and processes it. The data comes in as events - the
app is idle until another chunk of data comes...
|
by: samuraign |
last post by:
Hi,
My C-code is working properly in Cygwin.
But when I run the same code in VC++ or LCC,
I use to get stack overflow exception during run time.
It is not entring into my function from testbench....
|
by: Aled Hughes |
last post by:
Hi,
I've discovered a stack-overflow crash scenario when using CWinformsDialog
to show a managed UserControl as a dialog in MFC8.
Basically all you have to do is press ESCape whilst the...
|
by: pawel.kedzior |
last post by:
Hi
One of the issues which AppDomains are facing is problem of unsecure
code execution in a sandbox. One of its aspects are unhandled
exceptions thrown inside domains - they should not...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |