日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

排队论系统仿真c语言,排队论仿真程序

發布時間:2023/12/14 windows 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 排队论系统仿真c语言,排队论仿真程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

自己編的單服務M/M/1排隊論仿真程序,僅供參考!可在VC6.0中運行!

#include

#include

#include

#include

#include

typedef unsigned int eventtype;

double minuxexpdistribution(double dt);

typedef struct//this struct is used to regist events!

{

int No;

double time;

eventtype e;//1 arrive;2 start serving;3

leave;

int id;//person of event

int busy;

int quelen;

}eventtable;

int i=1;int j=1;int k=1;

eventtable tmp;int idtmp=1;int event;

eventtable tt={0,0,0,0,0,0};

eventtable?*pEventTable=&tt;

int xx[1000][1000]={0,0};//use a large piece of 0_zeros to seperate

pEventTable and arrive_t_reg!

double a0=0;

double *arrive_t_reg=&a0;

int xxx[1000][10000]={0};

double b0=0;

double *leave_t_reg=&b0;

void main()

{

double

TIMELIMIT,AvgServeTime,AvgArriveInterval;

cout<

simulatin TIMELIMIT:\n";

cin>>TIMELIMIT;

cout<

average serve time :\n";

cin>>AvgServeTime;

cout<

average arrive time interval :\n";

cin>>AvgArriveInterval;

cout<

srand((unsigned)time(NULL));

double t=0;//system clock

ofstream fout("EventTable.txt");

ofstream foutser("ServeTime.txt");

//set the first person

double leave;

double

arrive=minuxexpdistribution(AvgArriveInterval);

(*(arrive_t_reg+j))=arrive;

j++;

event=1;

t=arrive;

//int m=0;

fout<

fout<

fout<

代表事件類型,1為到達,2為開始服務,3為離開,上邊的語句表示,在0.889時刻1到達,在開始服務前,隊長為1.\n";

fout<

"<

"<

"<

foutser<

do

{

switch(event)

{

case 1:

arrive=minuxexpdistribution(AvgArriveInterval);//determine

the time interval of the next commer!

*(arrive_t_reg+j)=t+arrive;

//cout<

j++;

if((*(pEventTable+i-1)).busy==0&&(*(pEventTable+i-1)).quelen==0)

{

tmp.busy=0;

tmp.e=1;

tmp.id=idtmp;

tmp.No=i;

tmp.quelen=1;

tmp.time=*(arrive_t_reg+idtmp);

*(pEventTable+i)=tmp;

fout<

i++;

idtmp=tmp.id;

t=tmp.time;

event=2;

break;

}

if(

(*(pEventTable+i-1)).busy )//the server is busy!

{

tmp.quelen=(*(pEventTable+i-1)).quelen+1;

tmp.busy=1;

tmp.id=idtmp;

tmp.e=1;

tmp.time=t;

tmp.No=i;

*(pEventTable+i)=tmp;

fout<

if(

*(arrive_t_reg+idtmp+1)>*(leave_t_reg+k-1) )//the

person in service will leave before the next

comer!?{

t=*(leave_t_reg+k-1);

event=3;

idtmp=k-1;//???

break;

}

else//the

nearest comer will arrive before the person in service

leaves;

{

idtmp=tmp.id+1;

event=1;

t=*(arrive_t_reg+idtmp);

break;

}

}

case

2://start serve

tmp.busy=1;

tmp.quelen=(*(pEventTable+i-1)).quelen-1;

tmp.e=2;

tmp.id=idtmp;

tmp.No=i;

tmp.time=t;

*(pEventTable+i)=tmp;

fout<

leave=minuxexpdistribution(AvgServeTime);

foutser<

*(leave_t_reg+tmp.id)=t+leave;

k=tmp.id;

k++;

//arrive=minuxexpdistribution(AvgArriveInterval);//determine

time of the next comer

/

fout<

}

double minuxexpdistribution(double dt)

{

//srand((unsigned)time(NULL));

return -log(1-rand()/32767.0)*dt;

}

總結

以上是生活随笔為你收集整理的排队论系统仿真c语言,排队论仿真程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。