资源简介
排队论MM1模型的C++仿真程序,程序中输入lambda,mu和total arrival之后就可以根据参数进行仿真并得出一系列的统计结果
代码片段和文件信息
// EE 465 USC
// Simulation of an M/M/1 system
#include
#include
#include
#include
using namespace std;
#define INFIN 999999999
// Function Name: expon
// Description: Generates an exponentially distributed random number
// with parameter \lambda.
// Input: lambda (double)
// Output: An exponentially distributed random number (double)
//
double expon(double lambda)
{
double u; // used to store a random number.
do
{
u = drand48(); //uniform number in the interval [0.0 1.0]
}
while ((u == 0) || (u == 1)); //special cases that we want to avoid
return -log(1-u)/lambda;
}
// Function Name: print_stats
// Description: Saves and prints system statistics
// Input: stats_file (ostream object): ostream object for the stats file
// avg_customers (double): average customers in the system
// avg_service_time (double): average service time
// Output: void (output stored to file and printed in the screen)
//
void print_stats(ostream &stats_file double avg_customers double avg_service_time)
{
cout << “Average No. of Customers: “ << avg_customers << endl;
cout << “Average Service Time: “ << avg_service_time << endl;
stats_file << “Average No. of Customers: “ << avg_customers << endl;
stats_file << “Average Service Time: “ << avg_service_time << endl;
}
// The main function of the program that is called at the beginning.
int main() {
//system variables
long int tot_arrivals cur_arrivals = 0;
double lambda mu;
double event1 = 0.0 event2
相关资源
- win10下vs2015编译TensorFlow1.4 C++源码 CP
- VC++ MFC 的计算器的详细设计
- ftp客户端的C语言实现
- 银行账户管理系统c++)
- vc++ 和 openGL 做的 3D水波模拟 非常炫
- 分水岭图像分割算法 c++实现
- tcp udp 底层c++封装类windows和linux
- c++c#结构体转换工具
- 操作系统的模拟实现 C++编写
- VC++实现算数编码
- 贪吃蛇C++ graphics.h
- 利用MATLAB 改写的基于c++的模糊逻辑
- RS232串口通信C++
- 双语版 c++ 程序设计苏小红版 答案
- C++考试题库
- 天津工业大学C++语言期末考试题及答
- A*算法解决八数码问题C++
- 一个Oracle OCI编程接的C++封装,有OCI的
- CRC32和CRC16校验程序C++中用DLL实现
- AES 128位加解密C++源码(加盐)
- c++贪心法的最优服务次序问题
- 自适应模糊PID代码 C++实现
- 数据结构课程设计 排序综合(C++)
- 基于C++的HOSVD源代码
- VIsual C++实现的连连看游戏程序
- Thinking in c++ Annotated Solution Guide 答案
- c++ 最小堆实现
- opencv+udp+c++ 的摄像头实时传输显示源
- 稀疏矩阵运算器(c++)
- C++教程网 大并发高性能高可用可伸缩
评论
共有 条评论