Снимок работающей программы
Цель работы
Для СМО заданной конфигурации построить имитационную модель и исследовать ее
(разработать алгоритм и написать имитирующую программу, предусматривающую сбор и
статистическую обработку данных для получения оценок заданных характеристик СМО).
Распределение интервалов времени между заявками во входном потоке и интервалов времени
обслуживания – геометрическое с соответствующим параметром (ρ, π1, π2).
Исходные данные (Вариант 10)
Структура СМО:
ρ | π1 | π2 | Цель исследования |
0,5 | 0,45 | 0,35 | Q |
Анализ задания
Граф состояний кодируется четырёхкомпонентным вектором TNK1K2, где
T — время до выдачи очередной заявки источником, T = {2, 1, 0}:
2 — два такта до выдачи заявки;
1 — один такт до выдачи заявки;
0 — источник заблокирован.
N — длина очереди, N = {0, 1}:
0 — очередь пуста;
1 — одна заявка в очереди.
K1 и K2 — состояние каналов обслуживания, Ki = {0, 1}:
0 — канал свободен;
1 — канал занят.
Матрица переходов
|
Граф состояний
Расчёт параметров системы
Исходя из графа состояний получим систему уравнений:
0.325*p0001+0.179*p0011+0.5*p0000-p1010=0 0.275*p1010-0.725*p1011+0.175*p0001+0.275*p0010+0.096*p0011=0 0.07875*p1011+0.07875*p0011+0.354*p0111+0.275*p0110-p1111=0 0.225*p1010+0.146*p1011+0.5*p1111-0.5*p1110+0.225*p0010+0.146*p0011+0.146*p0111+0.225*p0110=0 0.275*p1010+0.275*p1011-0.825p0001+0.275*p0010+0.275*p0010=0 0.225*p1010+0.146*p1011+0.275*p1110-0.725*p0010+0.146*p0011=0 0.07875*p1011+0.275*p1111-0.921*p0011+0.275*p0111+0.275*p0110=0 0.07875*p1111-0,921*p0111=0 0.146*p1111+0.146*p0111+0.275*p1110-0.775*p0110=0 0.325*p0001-0.5*p0000=0 p1010+p1111+p1110+p0001+p0010+p0011+p0111+p0110+p0000+p1011=1 | |
Текст программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace l3
{
public partial class Form1 : Form
{
//
double x0 = 2014;
double a = 281;
double c = 28411;
double m = 134456;
double x1 = 0.0;
List<Label> labelaArr = new List<Label>();
string[,] arr = new string[,] {{"-", "1010", "1011", "1111", "1110", "0001", "0010", "0011", "0111", "0110", "0000" },
{"-","0","0","0","0","0","0","0","0","0","0"}};
double[] arr1 = new double[300];
Double findNumber = 0.0;
Double step1;
Double step2;
Double step3_main;
Double step3_part;
Double step4;
//
string[,] arrayState = new string[,] {{"-","1010","1011","1111","1110","0001","0010","0011","0111","0110","0000"},
{"1010","0","0,257","0","0,5","0,775","1","0","0","0","0"},
{"1011","0","0,257","0,354","0,5","0,775","0,921","1","0","0","0"},
{"1111","0","0","0","0,5","0","0","0,775","0,854","1","0"},
{"1110","0","0","0","0,5","0","0,775","0","0","1","0"},
{"0001","0,325","0,5","0","0","0,675","0","0","0","0","1"},
{"0010","0","0,275","0","0,5","0,775","1","0","0","0","0"},
{"0011","0,179","0,275","0,354","0,5","0,775","0,921","1","0","0","0"},
{"0111","0","0","0,354","0,5","0","0","0,775","0,854","1","0"},
{"0110","0","0","0,275","0,5","0","0","0,775","0","1","0"},
{"0000","0,5","0","0","0","0","0","0","0","0","1"}};
string[,] arrayData = new string[,] { {"0","0,257","0","0,225","0,275","0,225","0","0","0","0"},
{"0","0,257","0,07875","0,146","0,275","0,146","0,07875","0","0","0"},
{"0","0","0","0,5","0","0","0,275","0,07875","0,146","0"},
{"0","0","0","0,5","0","0,275","0","0","0,225","0"},
{"0,325","0,175","0","0","0,175","0","0","0","0","0,325"},
{"0","0,275","0","0,225","0,275","0,225","0","0","0","0"},
{"0,179","0,096","0,07875","0,146","0,275","0,146","0,07875","0","0","0"},
{"0","0","0,354","0,146","0","0","0,275","0,07875","0,146","0"},
{"0","0","0,275","0,225","0","0","0,275","0","0,225","0"},
{"0,5","0","0","0","0","0","0","0","0","0,5"}};
public Form1()
{
InitializeComponent();
labelaArr.Add(label1);
labelaArr.Add(label2);
labelaArr.Add(label3);
labelaArr.Add(label4);
labelaArr.Add(label5);
labelaArr.Add(label6);
labelaArr.Add(label7);
labelaArr.Add(label8);
labelaArr.Add(label9);
labelaArr.Add(label10);
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
dataGridView1.Rows.Add();
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
dataGridView1.Rows[i].Cells[j].Value = arrayData[i, j];
}
}
}
private void button1_Click(object sender, EventArgs e)
{
string beginState = "0000";
for (int i = 0; i < 1000; i++)
{
x1 = x0;
findNumber = s_part(x1);
x0 = s_main(x1);
listBox1.Items.Add(findNumber.ToString().Remove(5));
for (int i_i = 0; i_i < 11; i_i++)
{
if (beginState.Equals(arrayState[i_i, 0]))
{
for (int j_j = 1; j_j < 11; j_j++)
{
if (findNumber < Convert.ToDouble(arrayState[i_i, j_j]))
{
beginState = arrayState[0, j_j];
listBox2.Items.Add(beginState);
arr[1, j_j] = (Convert.ToInt32(arr[1, j_j]) + 1).ToString();
break;
}
}
}
}
}
int counter = 1;
for (int i = 0; i < 10; i++)
{
labelaArr[i].Text += " - - " + (Convert.ToDouble(Convert.ToDouble(arr[1, counter])) / 1000).ToString();
counter++;
}
}
private double s_part(double x0_)
{
step1 = 0.0;
step2 = 0.0;
step3_main = 0.0;
step3_part = 0.0;
step4 = 0.0;
//step one
step1 = x0_ * a;
//step two
step2 = step1 + c;
//step three
step3_main = step2 / m;//целая часть
step3_part = step2 % m;//остаток от деления
//step four
step4 = step3_part / m;
return step4;
}
private double s_main(double x0_)
{
step1 = 0.0;
step2 = 0.0;
step3_main = 0.0;
step3_part = 0.0;
step4 = 0.0;
//step one
step1 = x0_ * a;
//step two
step2 = step1 + c;
//step three
step3_main = step2 % m;//целая часть
return step3_main;
}
}
}
Снимок работающей программы