Главная страница

вкр. ВКР Лазарева. Имитационное моделирование систем массового обслуживания с динамическим приоритетом


Скачать 1.02 Mb.
НазваниеИмитационное моделирование систем массового обслуживания с динамическим приоритетом
Дата07.01.2023
Размер1.02 Mb.
Формат файлаdocx
Имя файлаВКР Лазарева.docx
ТипДокументы
#875109
страница5 из 5
1   2   3   4   5

ПРИЛОЖЕНИЯ




Приложение 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 Kursovaya1

{

public partial class Form1 : Form

{
//рандомизация

Random rand = new Random();
public int N, q1 , q2 , n;
public double lambda1, lambda2, mu1, mu2, delta, T;
private void Grafik2_Click(object sender, EventArgs e)

{
}
private void button2_Click(object sender, EventArgs e)

{

for (int j = 1; j <= nomer_g; j++)

{

grafik1.Series["График" + Convert.ToString(j)].Points.Clear();

grafik2.Series["График" + Convert.ToString(j)].Points.Clear();

grafik3.Series["График" + Convert.ToString(j)].Points.Clear();

grafik4.Series["График" + Convert.ToString(j)].Points.Clear();

grafik5.Series["График" + Convert.ToString(j)].Points.Clear();

grafik6.Series["График" + Convert.ToString(j)].Points.Clear();

grafik7.Series["График" + Convert.ToString(j)].Points.Clear();

grafik4.Series["Среднее" + Convert.ToString(j)].Points.Clear();

grafik7.Series["Среднее" + Convert.ToString(j)].Points.Clear();

grafik8.Series["График" + Convert.ToString(j)].Points.Clear();

}

}
private bool skachok(double koef) //функция скачка

{

double teta = rand.NextDouble();

if (teta >= 0.5 && teta <= 0.5 + koef * delta)

{

return true;

}

else

{

return false;

}

}
public Form1()

{

InitializeComponent();

}
int nomer_g = 0;
public void button1_Click(object sender, EventArgs e)

{

if ((textBox1.Text == "") && (textBox2.Text == "") && //проверка заполненности входных данных

(textBox3.Text == "") && (textBox4.Text == "") &&

(textBox5.Text == "") && (textBox6.Text == "") &&

(textBox7.Text == ""))

{

DialogResult result = MessageBox.Show(

"Введите значение",

"Attention",

MessageBoxButtons.OK,

MessageBoxIcon.Information,

MessageBoxDefaultButton.Button3,

MessageBoxOptions.DefaultDesktopOnly);

if (result == DialogResult.OK)

return;

}
T = Convert.ToDouble(textBox1.Text);

lambda1 = Convert.ToDouble(textBox2.Text);

mu1 = Convert.ToDouble(textBox5.Text);

N = Convert.ToInt32(textBox7.Text);

n = Convert.ToInt32(textBox8.Text);

delta = Convert.ToDouble(textBox4.Text);

lambda2 = Convert.ToDouble(textBox3.Text);

mu2 = Convert.ToDouble(textBox6.Text);

int shagi = Convert.ToInt32(T / delta);

double Y_max = lambda1 * T;
grafik1.ChartAreas[0].AxisX.Minimum = 0;

grafik1.ChartAreas[0].AxisX.Maximum = T;

grafik1.ChartAreas[0].AxisX.Interval = T / 10;

grafik1.ChartAreas[0].AxisY.Minimum = 0;

grafik1.ChartAreas[0].AxisY.Maximum = 10;

grafik1.ChartAreas[0].AxisY.Interval = 1;
grafik2.ChartAreas[0].AxisX.Minimum = 0;

grafik2.ChartAreas[0].AxisX.Maximum = T;

grafik2.ChartAreas[0].AxisX.Interval = T / 10;

grafik2.ChartAreas[0].AxisY.Minimum = 0;

grafik2.ChartAreas[0].AxisY.Maximum = Y_max;

grafik2.ChartAreas[0].AxisY.Interval = Y_max / 5;
grafik3.ChartAreas[0].AxisX.Minimum = 0;

grafik3.ChartAreas[0].AxisX.Maximum = T;

grafik3.ChartAreas[0].AxisX.Interval = T / 10;

grafik3.ChartAreas[0].AxisY.Minimum = 0;

grafik3.ChartAreas[0].AxisY.Maximum = Y_max;

grafik3.ChartAreas[0].AxisY.Interval = Y_max / 5;
grafik4.ChartAreas[0].AxisX.Minimum = 0;

grafik4.ChartAreas[0].AxisX.Maximum = T;

grafik4.ChartAreas[0].AxisX.Interval = T / 10;

grafik4.ChartAreas[0].AxisY.Minimum = 0;

grafik4.ChartAreas[0].AxisY.Maximum = Y_max;

grafik4.ChartAreas[0].AxisY.Interval = Y_max / 5;
grafik5.ChartAreas[0].AxisX.Minimum = 0;

grafik5.ChartAreas[0].AxisX.Maximum = T;

grafik5.ChartAreas[0].AxisX.Interval = T / 10;

grafik5.ChartAreas[0].AxisY.Minimum = 0;

grafik5.ChartAreas[0].AxisY.Maximum = Y_max;

grafik5.ChartAreas[0].AxisY.Interval = Y_max / 5;
grafik6.ChartAreas[0].AxisX.Minimum = 0;

grafik6.ChartAreas[0].AxisX.Maximum = T;

grafik6.ChartAreas[0].AxisX.Interval = T / 10;

grafik6.ChartAreas[0].AxisY.Minimum = 0;

grafik6.ChartAreas[0].AxisY.Maximum = Y_max;

grafik6.ChartAreas[0].AxisY.Interval = Y_max / 5;
grafik7.ChartAreas[0].AxisX.Minimum = 0;

grafik7.ChartAreas[0].AxisX.Maximum = T;

grafik7.ChartAreas[0].AxisX.Interval = T / 10;

grafik7.ChartAreas[0].AxisY.Minimum = 0;

grafik7.ChartAreas[0].AxisY.Maximum = Y_max;

grafik7.ChartAreas[0].AxisY.Interval = Y_max / 5;
grafik8.ChartAreas[0].AxisX.Minimum = 0;

grafik8.ChartAreas[0].AxisX.Maximum = T;

grafik8.ChartAreas[0].AxisX.Interval = T / 10;

grafik8.ChartAreas[0].AxisY.Minimum = 0;

grafik8.ChartAreas[0].AxisY.Maximum = 10;

grafik8.ChartAreas[0].AxisY.Interval = 1;
var matk1 = new List();

var matk2 = new List();
for (int i = 0; i <= shagi; i++)

{

matk1.Add(0);

matk2.Add(0);

}
int k1 = 0;

int p1 = 0;

int p2 = 0;

int k2 = 0;

int p3 = 0;

int p4 = 0;

q1 = 0;

q2 = 0;
int ind = 0;
nomer_g++;


grafik1.Series.Add("График" + Convert.ToString(nomer_g));

grafik1.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik1.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik1.Legends.Clear();
grafik2.Series.Add("График" + Convert.ToString(nomer_g));

grafik2.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik2.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik2.Legends.Clear();
grafik3.Series.Add("График" + Convert.ToString(nomer_g));

grafik3.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik3.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik3.Legends.Clear();
grafik4.Series.Add("График" + Convert.ToString(nomer_g));

grafik4.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik4.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik4.Legends.Clear();
grafik5.Series.Add("График" + Convert.ToString(nomer_g));

grafik5.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik5.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik5.Legends.Clear();
grafik6.Series.Add("График" + Convert.ToString(nomer_g));

grafik6.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik6.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik6.Legends.Clear();
grafik7.Series.Add("График" + Convert.ToString(nomer_g));

grafik7.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik7.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik7.Legends.Clear();
grafik8.Series.Add("График" + Convert.ToString(nomer_g));

grafik8.Series["График" + Convert.ToString(nomer_g)].Color = Color.DarkRed;

grafik8.Series["График" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik8.Legends.Clear();
for (int j = 0; j < N; j++)

{

for (double i = 0; i <= T; i = i + delta)

{

if (skachok(lambda1))

{
grafik2.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p1);

p1++;

grafik2.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p1);

grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k1);

k1++;

grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k1);
if (k1+ k2 > n)

{

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q1);

q1++;

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q1);

}

}
if (skachok(lambda2))

{
grafik5.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p2);

p2++;

grafik5.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p2);

grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k2);

k2++;

grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k2);

if (k1 + k2 > n)

{

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q2);

q2++;

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q2);

}

}
if(skachok(mu1*(k1 - q1)))

{

grafik3.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p3);

p3++;

grafik3.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p3);

grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k1);

k1--;

grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k1);
if (q2 == 0)

{

if(q1 > 0)

{

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q1);

q1--;

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q1);

}
}

else

{

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q2);

q2--;

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q2);

}

}
if (skachok(mu2*(k2 -q2)))

{

grafik6.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p4);

p4++;

grafik6.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, p4);

grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k2);

k2--;

grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, k2);
if (q1 == 0)

{

if (q2 > 0)

{

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q2);

q2--;

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q2);

}

}

else

{

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q1);

q1--;

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(i, q1);

}


}
matk1[ind] = (j * matk1[ind] + k1) / (j + 1);

matk2[ind] = (j * matk2[ind] + k2) / (j + 1);

ind++;

}
grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, q1);

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik1.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik2.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, p1);

grafik2.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik2.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik3.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, p3);

grafik3.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik3.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, k1);

grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik4.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik5.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, p2);

grafik5.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik5.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik6.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, p4);

grafik6.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik6.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, k2);

grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik7.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, q2);

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(T * 10, 0);

grafik8.Series["График" + Convert.ToString(nomer_g)].Points.AddXY(0, 0);
p1 = 0;

p2 = 0;

k1 = 0;

k2 = 0;

p3 = 0;

p4 = 0;

ind = 0;

q1 = 0;

q2 = 0;

}
grafik4.Series.Add("Среднее" + Convert.ToString(nomer_g));

grafik4.Series["Среднее" + Convert.ToString(nomer_g)].Color = Color.Black;

grafik4.Series["Среднее" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik4.Legends.Clear();
grafik7.Series.Add("Среднее" + Convert.ToString(nomer_g));

grafik7.Series["Среднее" + Convert.ToString(nomer_g)].Color = Color.Black;

grafik7.Series["Среднее" + Convert.ToString(nomer_g)].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

grafik7.Legends.Clear();
for (double i = 0; i <= T; i = i + delta)

{

grafik4.Series["Среднее" + Convert.ToString(nomer_g)].Points.AddXY(i, matk1[ind]);

grafik7.Series["Среднее" + Convert.ToString(nomer_g)].Points.AddXY(i, matk2[ind]);

ind++;

}
matk1.Clear();

matk2.Clear();

}

}

}


Приложение 2. Блок-схема программы




1   2   3   4   5


написать администратору сайта