資源簡介
多隊列模擬
?????? 說明:一個傳輸系統受3個輸入和只有一個服務器。 所有輸入都以泊松過程為特征,服務時間遵循指數分布。
?????? 目標:探索一個能夠公平地把服務分配給任何性能測量的輸入的調度方案; 獲得每個隊列的平均隊列長度,平均等待時間,隊列長度分布和等待時間分布。 報告中應包括任何必要的解釋和說明。
Multi-queue simulation
Description: a transmission system subject to 3 inputs and only one server. All inputs are characterized by Poisson process and the service time follows an exponential distribution.
Goal: explore a scheduling scheme which is able to allocate the service fairly to each of the input in terms of any performance measurement; obtaining the mean queue length, mean waiting time, queue length distribution and waiting time distribution for each queue. Any necessary explaination and statement should be included in the report.
代碼片段和文件信息
/*
?*?To?change?this?license?header?choose?License?Headers?in?Project?Properties.
?*?To?change?this?template?file?choose?Tools?|?Templates
?*?and?open?the?template?in?the?editor.
?*/
package?computernetwork;
import?com.sun.jmx.remote.internal.ArrayQueue;
import?java.io.File;
import?java.io.FileNotFoundException;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.text.SimpleDateFormat;
import?java.util.ArrayDeque;
import?java.util.ArrayList;
import?static?java.util.Collections.list;
import?java.util.Date;
import?java.util.Iterator;
import?java.util.linkedList;
import?java.util.List;
import?java.util.Queue;
import?java.util.Random;
import?java.util.logging.Level;
import?java.util.logging.Logger;
/**
?*
?*?@author?ASUS
?*/
class?MyDouble
{
????public?MyDouble(double?d)
????{
????????this.d?=?d;
????}
????double?size;
????double?d;
????public?void?Add(double?d)
????{
????????this.d?+=?d;
????}
}
public?class?MM3
{
????String?info?=?““;
????MyRandom?random;
????int?next_event_type?num_events;
????double[]?mean_interarrival?=?new?double[3];//各隊列平均到達時間
????double?sim_time?mean_service?end_time;
????double?time_next_event[]?=?new?double[4];??//第四個時間是離開
????double?tn;
????double?chizhi[]?=?new?double[3];//各自隊列赤字
????int?now_q?=?0;//當前隊列
????double?xiane;//每次限額
????boolean?isServerBusy?=?false;
????List>?wait_q?=?new?ArrayList<>();
????//隊列中等待的時間
????int?last_q;//上次被調度的隊列
????int?x_max?=?100;//橫坐標數組大小
????double[][]?q_lenth?=?new?double[3][x_max];//3條隊列長度分布
????double[][]?q_wait?=?new?double[3][x_max];//3條隊列時間分布
????double?wait_gap;//橫坐標數組間距
????double?sum_time;
????int?num_of_sent[]?=?new?int[3];
????int?num_of_come[]?=?new?int[3];
????public?void?start()
????{
????????new?Thread(this.new?Timer(this)).start();//計時器
????????while?(sim_time?????????{
????????????timing();
????????????switch?(next_event_type)
????????????{
????????????????case?0:
????????????????case?1:
????????????????case?2:
????????????????????arrive();
????????????????????break;
????????????????case?3:
????????????????????depart();
????????????????????break;
????????????}
????????}
????}
????public?void?init()
????{
????????for?(int?i?=?0;?i?3;?i++)
????????{
????????????wait_q.add(new?ArrayDeque<>());
????????}
????????random?=?new?MyRandom();
????????sim_time?=?0.0;
????????end_time?=?1.0E6;
????????num_events?=?4;
????????mean_interarrival[0]?=?3;
????????mean_interarrival[1]?=?3.2;
????????mean_interarrival[2]?=?2.8;
????????mean_service?=?0.99;
????????xiane?=?1;
????????wait_gap?=?0.2;
????????for?(int?i?=?0;?i?3;?i++)
????????{
????????????time_next_event[i]?=?MyRandom.getExponentialVariable(1.0/mean_interarrival[i]);//獲得
????????}
????????time_next_event[3]?=?1.1e+10;
????}
//????public?double?getExponentialVariable(double?lamda)
//????{
//????????double?x?z;
//????????do
//????????{
//??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3630??2017-10-15?10:36??ComputerNetwork\build.xm
?????目錄???????????0??2017-10-15?10:49??ComputerNetwork\build\
?????目錄???????????0??2017-10-15?10:49??ComputerNetwork\build\classes\
?????文件???????????0??2017-10-15?10:49??ComputerNetwork\build\classes\.netbeans_automatic_build
?????文件???????????0??2017-10-15?10:49??ComputerNetwork\build\classes\.netbeans_update_resources
?????目錄???????????0??2017-11-19?18:36??ComputerNetwork\build\classes\computernetwork\
?????文件????????2030??2017-11-19?18:36??ComputerNetwork\build\classes\computernetwork\MM3$Timer.class
?????文件????????8362??2017-11-19?18:36??ComputerNetwork\build\classes\computernetwork\MM3.class
?????文件?????????434??2017-11-19?18:36??ComputerNetwork\build\classes\computernetwork\MyDouble.class
?????文件????????3350??2017-11-18?10:52??ComputerNetwork\build\classes\computernetwork\MyRandom.class
?????文件??????????85??2017-10-15?10:36??ComputerNetwork\manifest.mf
?????目錄???????????0??2017-10-15?10:36??ComputerNetwork\nbproject\
?????文件???????79355??2017-10-15?10:36??ComputerNetwork\nbproject\build-impl.xm
?????文件?????????475??2017-10-15?10:36??ComputerNetwork\nbproject\genfiles.properties
?????目錄???????????0??2017-10-17?19:49??ComputerNetwork\nbproject\private\
?????文件?????????111??2017-10-15?10:36??ComputerNetwork\nbproject\private\private.properties
?????文件?????????539??2017-11-18?16:42??ComputerNetwork\nbproject\private\private.xm
?????文件????????2461??2017-11-17?13:52??ComputerNetwork\nbproject\project.properties
?????文件?????????523??2017-10-15?10:36??ComputerNetwork\nbproject\project.xm
?????目錄???????????0??2017-10-15?10:36??ComputerNetwork\src\
?????目錄???????????0??2017-11-16?19:04??ComputerNetwork\src\computernetwork\
?????文件???????12147??2017-11-19?18:36??ComputerNetwork\src\computernetwork\MM3.java
?????文件????????5082??2017-11-18?10:52??ComputerNetwork\src\computernetwork\MyRandom.java
- 上一篇:JAVA 模擬時鐘實驗報告
- 下一篇:xm
l-apis-2.0.2.jar
評論
共有 條評論