51203

Аналитическое моделирование дискретно-стохастической СМО

Лабораторная работа

Информатика, кибернетика и программирование

Цель: Построить граф состояний СМО . Смысл кодировки состояний раскрыть (время до выдачи заявки, число заявок в накопителе и т.д.). На схеме условно обозначены

Русский

2014-02-07

241.97 KB

90 чел.

БЕЛОРУССКИЙ ГОСУДАРСТВЕННЫЙ УНИВЕРСИТЕТ ИНФОРМАТИКИ И РАДИОЭЛЕКТРОНИКИ

Кафедра ПОИТ

Отчёт

по лабораторной работе №3

“ Аналитическое моделирование дискретно - стохастической СМО ”

Вариант 11

Проверил:         Выполнил:

Мельник Н.И.       ст.гр. 750505

Мицкевич А.В.                    

Минск 2010

Цель:

Построить граф состояний СМО .  Смысл кодировки состояний раскрыть (время до выдачи заявки, число заявок в накопителе и т.д.).

На схеме условно обозначены

Источник с фиксированным временем ожидания выдачи заявки

2

Канал с вероятностью просеивания (не обслуживания заявки)

Источник/канал с дисциплиной отбрасывания заявки

Накопитель на N заявок

N

По графу построить аналитическую модель и, решив ее, определить вероятности состояний. Рассчитать теоретическое значение показателя абсолютной пропускной способности А.

Также  построить имитационную модель и исследовать ее (разработать алгоритм и написать имитирующую программу, предусматривающую сбор и статистическую обработку данных для получения оценок заданных характеристик СМО). Распределение интервалов времени между заявками во входном потоке и интервалов времени обслуживания – геометрическое с соответствующим параметром (2, π1, π2).

П1=0,4

П2=0,4

Выполнение  лабораторной работы:

Построение графа  состояний СМО.

Теоретические расчеты:

Построение имитационной программы.

Скриншот программы.

Листинг программы.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace laba3_model

{

   public partial class Form1 : Form

   {

       Point st1 = new Point();

       Point st2 = new Point();

       Point st3 = new Point();

       Point st4 = new Point();

       Random random;

       bool flag=false;

       int Potk = 0;

       int chek_kol=0;

       int t;

       int j;

       int s1;

       int s2;

       double tmp,tmp1;

       double p1 ;

       double p2 ;

       int otbr = 0;

       public Form1()

       {

           random = new Random();

           t=2;

           j = 0;

           s1 = 0;

           s2 = 0;

           p1 = 0;

           p2 = 0;

           

           InitializeComponent();

 

       }

      

       private void pictureBox1_Paint(object sender, PaintEventArgs e)

       {

           st1.X = 20;

           st1.Y = 45;

           e.Graphics.DrawString(t.ToString(), new Font("Arial", 30), new SolidBrush(Color.Black), st1);

           st2.X = 140;

           st2.Y = 45;

           e.Graphics.DrawString(j.ToString(), new Font("Arial", 30), new SolidBrush(Color.Black), st2);

           st3.X = 245;

           st3.Y = 45;

           e.Graphics.DrawString(s1.ToString(), new Font("Arial", 30), new SolidBrush(Color.Black), st3);

           st4.X = 350;

           st4.Y = 48;

           e.Graphics.DrawString(s2.ToString(), new Font("Arial", 30), new SolidBrush(Color.Black), st4);

       }

       double rand()

       {

           return  (double)random.Next(0, 100)/100.000;

       }

      

       void fun()

       {

           label4.Text = "p1=" + p1.ToString();

           label5.Text = "p2=" + p2.ToString();

           switch (t)

           {

               case 2:

                   switch (j)

                   {

                       case 0:

                           switch (s1)

                           {

                               case 0:

                                   switch (s2)

                                   {

                                       case 0:  //2000

                                                t = 1; j = 0; s1 = 0; s2 = 0;

                                               break;

                                       case 1: //2001

                                           break;

                                   } break;

                               case 1:

                                   switch (s2)

                                   {

                                       case 0: //2010

                                           tmp = rand();

                                           if (tmp > p2) { t = 1; j = 0; s1 = 0; s2 = 1; }

                                           else { t = 1; j = 0; s1 = 1; s2 = 0; } break;

                                       case 1:  //2011

                                           tmp=rand();

                                           if (tmp <= p1 * p2) { t = 1; j = 0; s1 = 1; s2 = 0; }

                                           else

                                           {

                                               if (tmp > p1 * p2 && tmp <= (1 - p2) * p1) { t = 1; j = 0; s1 = 1; s2 = 0; }

                                               else

                                               { t = 1; j = 0; s1 = 0; s2 = 1; otbr++; }

                                           }break;                                            

                                   } break;

                           }break;

                       case 2:       

                           switch (s1)

                           {

                               case 0:

                                   switch (s2)

                                   {

                                       case 0:  // 2200                                                

                                               break;

                                       case 1:  //2201

                                           break;

                                   } break;

                               case 1:

                                   switch (s2)

                                   {

                                       case 0://2210

                                           tmp = rand();

                                           if (tmp <= p1) { t = 1; j = 2; s1 = 1; s2 = 0; }

                                           else { t = 1; j = 1; s1 = 1; s2 = 1;}

                                            break;

                                       case 1:  //2211

                                            tmp=rand();

                                            if (tmp <= p1 * p2) { t = 1; j = 2; s1 = 1; s2 = 1; }

                                            else

                                            {

                                                if (tmp > p1 * p2 && tmp <= (1 - p2) * p1) { t = 1; j = 2; s1 = 1; s2 = 0; }

                                                else

                                                   { t = 1; j = 1; s1 = 1; s2 = 1; otbr++; }

                                            }

                                            break;

                                   } break;             

                           } break;

                       case 1:

                           switch (s1)

                           {

                               case 0:

                                   switch (s2)

                                   {

                                       case 0://2100--net

                                           break;

                                       case 1://2101--net

                                           break;

                                   } break;

                               case 1:

                                   switch (s2)

                                   {

                                       case 0: //2110

                                           tmp = rand();

                                           if (tmp > p1) { t = 1; j = 0; s1 = 1; s2 = 1; }

                                           else { t = 1; j = 1; s1 = 1; s2 = 0; }

                                           break;

                                       case 1: //2111

                                           tmp = rand();

                                           if (tmp <= (p1 * p2)) { t = 1; j = 1; s1 = 1; s2 = 1; }

                                           else

                                           {

                                               if (tmp > (p1 * p2) && tmp <= (1 - p2) * p1) { t = 1; j = 1; s1 = 1; s2 = 0; }

                                               else

                                                { t = 1; j = 0; s1 = 1; s2 = 1; otbr++; }

                                           }break;                                            

                                   } break;

                           } break;

                   } break;

               case 1:

                   switch (j)

                   {

                       case 0:

                           switch (s1)

                           {

                               case 0:

                                   switch (s2)

                                   {

                                       case 0://1000                                            

                                           t = 2; j = 0; s1 = 1; s2 = 0;                                                                                        

                                           break;

                                       case 1: //1001

                                           tmp = rand();

                                           if (tmp > p2) { t = 2; j = 0; s1 = 1; s2 = 0; }

                                           else { t = 2; j = 0; s1 = 1; s2 = 1; }                                                                                                                                                                                     

                                           break;

                                   } break;

                               case 1:

                                   switch (s2)

                                   {

                                       case 0://1010

                                           tmp = rand();

                                           if (tmp < p2) { t = 2; j = 1; s1 = 1; s2 = 0; }

                                           else { t = 2; j = 0; s1 = 1; s2 = 1; }                                            

                                           break;

                                       case 1://1011

                                           tmp = rand();

                                           if (tmp <= (p1 * p2)) { t = 2; j = 1; s1 = 1; s2 = 1; }

                                           else

                                           {

                                               if (tmp > (p1 * p2) && tmp <= (1 - p2) * p1) { t = 2; j = 1; s1 = 1; s2 = 0; }

                                               else

                                                   { t = 2; j = 0; s1 = 1; s2 = 1; otbr++; }

                                           }

                                           break;

                                   } break;

                           } break;

                       case 2:       

                           switch (s1)

                           {

                               case 0:

                                   switch (s2)

                                   {

                                       case 0:  // 1200                                                

                                               break;

                                       case 1:  //1201

                                           break;

                                   } break;

                               case 1:

                                   switch (s2)

                                   {

                                       case 0://1210

                                           tmp = rand();

                                           if (tmp <= p1) { t = 2; j = 2; s1 = 1; s2 = 0; }

                                           else { t = 2; j = 2; s1 = 1; s2 = 1; }

                                            break;

                                       case 1:  //1211

                                            tmp = rand();

                                            if (tmp <= (1 - p2) * p1) { t = 2; j = 2; s1 = 1; s2 = 0;}

                                            else { t = 2; j = 2; s1 = 1; s2 = 1; otbr++; }                                                 

                                            break;

                                   } break;             

                           } break;  

                       case 1:

                           switch (s1)

                           {

                               case 0:

                                   switch (s2)

                                   {

                                       case 0://1100--net

                                           break;

                                       case 1://1101--net

                                           break;

                                   } break;

                               case 1:

                                   switch (s2)

                                   {

                                       case 0://1110

                                           tmp = rand();

                                           if (tmp <= p1) { t = 2; j = 2; s1 = 1; s2 = 0; }

                                           else { t = 2; j = 1; s1 = 1; s2 = 1; }

                                           break;

                                       case 1://1111

                                           tmp = rand();

                                           if (tmp <= (p1 * p2)) { t = 2; j = 2; s1 = 1; s2 = 1; }

                                           else

                                           {

                                               if (tmp > (p1 * p2) && tmp <= (1 - p2) * p1) { t = 2; j = 2; s1 = 1; s2 = 0; }

                                               else

                                                  { t = 2; j = 1; s1 = 1; s2 = 1; otbr++; }

                                           }

                                           break;

                                   } break;

                           } break;           

                   } break;

           }

           chek_kol++;

       }

       private void button1_Click(object sender, EventArgs e)

       {

           string txt = "";     

           if (flag==false)

           {

               

               fun();

               double tmp2=0;

               tmp1 = (double)chek_kol / 2.00;

               int p;

               p = chek_kol / 2;               

               if (Potk == 0) label1.Text = "Pотказа=???";

               else

               {                    

                   tmp2 = (double)Potk / (double)chek_kol;           

                   tmp2 *= 2;                   

               }                

           }

           else

           {

               Potk = 0;   // БЕЗ НАКАПЛИВАНИЯ

               chek_kol = 0;

               try

               {

                   listBox1.Items.Clear();

                   t = 2;

                   j = 0;

                   s1 = 0;

                   s2 = 0;

                   this.backgroundWorker1.RunWorkerAsync(2000);

                   otbr = 0;

                   for (int i = 0; i < 20000; i++)

                   {                        

                       txt = "";

                       txt = txt + t.ToString() + " " + j.ToString() + " " + s1.ToString() + " " + s2.ToString();                     

                       listBox1.Items.Add(txt);

                       fun();

                   }

                   double pie=otbr / 2;

                   label6.Text = "Кол отброс = " + pie.ToString();

                   label7.Text = "Кол заяыок = " + chek_kol.ToString();

                   double aps=(double)(chek_kol/2 - otbr) / (double)chek_kol;

                   label1.Text = "АПС="+ aps.ToString();

                   if (Potk == 0)

                   {                        

                       tmp1 = (double)Potk / (double)chek_kol;                     

                   }

                   else

                   {

                       chek_kol /= 2;                       

                       tmp1 = (double)Potk / (double)chek_kol;                                               

                   }

               }

               catch { };

           }

           txt = "";

           pictureBox1.Invalidate();      

           txt = txt + t.ToString()+" " + j.ToString() +" "+ s1.ToString() +" "+ s2.ToString();            

           listBox1.Items.Add(txt);            

       }

       private void radioButton2_CheckedChanged(object sender, EventArgs e)

       {

           Potk = 0;

           chek_kol=0;            

           listBox1.Items.Clear();

           flag = true;

       }

       private void Вручную_CheckedChanged(object sender, EventArgs e)

       {

           Potk = 0;

           chek_kol = 0;

           t = 2;

           j = 0;

           s1 = 0;

           s2 = 0;            

           listBox1.Items.Clear();

           flag = false;

       }

       private void textBox1_TextChanged(object sender, EventArgs e)

       {

          

       }

       private void button2_Click(object sender, EventArgs e)

       {

           try

           {

               if (textBox1.Text != "")

                   p1 = Convert.ToDouble(textBox1.Text);

               else p1 = 0.8;

               if (textBox2.Text != "")

                   p2 = Convert.ToDouble(textBox2.Text);

               else p2 = 0.6;

               label4.Text = "p1=" + p1.ToString();

               label5.Text = "p2=" + p2.ToString();

               t = 2;

               j = 0;

               s1 = 0;

               s2 = 0;

           }

           catch { };            

       }

       private void pictureBox1_Click(object sender, EventArgs e)

       {

       }

       private void progressChange(object sender, ProgressChangedEventArgs e)

       {

       }

   }

}

Вывод:

В результате лабораторной  работы были построены имитационная и аналитическая модели,

Были исследованы характеристики данных моделей.


 

А также другие работы, которые могут Вас заинтересовать

15100. Фолклористикадағы миф 38.5 KB
  ФОЛКЛОРИСТИКАДАҒЫ МИФ ОНДАҒЫ ФЕТИШИЗМ МЕН АНИМИЗМ ТАБУ НАНЫМСЕНІМ МӘСЕЛЕЛЕРІ М. Иманғазинов Б. Есімбекова І. Жансүгіров атындағы Жетісу мемлекеттік университеті Талдықорған қ. Ы. Алтынсарин атындағы Қазақ білім академиясы Алматы қ. Мелеагр жөніндегі а...
15101. Француз романтизмі 50 KB
  ХІХ ғасырдағы шетел әдебиетінің тарихы Романтизм дәуірі Француз романтизмі Франциядағы романтизм тағдырының өзіндік ерекшелігі аталмыш жалпыеур
15103. ХІХ ғасырдағы Қазақ әдебиеті және оның зерттелуі 63 KB
  ХІХ ғасырдағы қазақ әдебиетінің тарихы зерттелуі. Қазақ әдебиеті тарихының төртінші томында ХІХ ғасырдың бірінші жартысындағы әдеби процестерге талдау жасалға ал бесінші томы осы ғасырдығ ІІ жартысына арналады. Сол кезеңдегі әдебиеттің даму ерекшеліктері сарапт
15104. ХХ ғасырдың ұлы жырауы 79 KB
  ХХ ғасырдың ұлы жырауы Жүз жыл өмірінің сексен бесін өлеңмен өткізген Жәкең – екі ғасырдың куәсі ғана болған жоқ. Оның жүз жылғы өмірі шындап келгенде екі ғасырға тең еді. Өйткені Жамбыл тарихта сирек кездесетін мүлде қарамақарсы екі заманды көрді қайшылыққа толы ...
15105. Ш. Мұртаза әңгімелеріндегі диалогтің кейіпкер мінезін ашу, образ жасаудағы рөлі 63.5 KB
  УДК. ӘОЖ 82 091 574 Т 50 ШЕРХАН МҰРТАЗА ӘҢГІМЕЛЕРІНДЕГІ ДИАЛОГТЫҢ КЕЙІПКЕР МІНЕЗІН АШУ ОБРАЗ ЖАСАУДАҒЫ РӨЛІ А. Тойшыбекова Тараз мемлекеттік педагогикалық инситуты Тараз қ. Шерхан Мұртазаның қаламгер болып қалыптасуына баспасөзде жұмыс жасаға...
15106. Шәді ақынның діни тақырыптағы дастандары 46.5 KB
  ШЄДІ АЌЫННЫЊ ДІНИ ТАЌЫРЫПТАЃЫ ДАСТАНДАРЫ Д. Сейітмратова А. Мќашева Тараз мемлекеттік педагогикалыќ институты Тараз қ. Қазақ елініњ оқу мен өнерді үйренуініњ аса қажет екенін насихаттап халық тарихына елжұ...
15108. Шәкәрім А.С.Пушкиннің Дубровский шығармасын қалай аударған еді 66 KB
  Шәкәрім А.С.Пушкиннің €œДубровский€ шығармасын қалай аударған еді Задан ЖҰМАҒАЛИ филология ғылымдарының докторы профессор. Абайдың тікелей қатысумен бірсыпыра деңгейге көтеріліп қалған қазақорыс әдеби байланысының одан әрмен дамуына зор үлес қосқан алаш ар