51203

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

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

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

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

Русский

2014-02-07

241.97 KB

76 чел.

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

Кафедра ПОИТ

Отчёт

по лабораторной работе №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)

       {

       }

   }

}

Вывод:

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

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


 

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

49381. Создание и обработка баз данных. Реализация функций информационной технологии в Access 744 KB
  Система управления базами данных Аccess Система управления базами данных ccess Общие положения База данных –- это организованная структура предназначенная для хранения информации. Однако сегодня большинство систем управления базами данных СУБД позволяют размешать в своих структурах не только данные но и методы то есть программный код с помощью которых происходит взаимодействие с потребителем или другими программно-аппаратными комплексами.
49387. Проектирование линейной автоматической системы управления 1.07 MB
  Цель работы: для заданного объекта регулирования требуется спроектировать АСР с заданным типом регулятора (ПИ-регулятор). Процесс проектирования состоит из следующих этапов: Анализ объекта регулирования. Определение оптимальных настроек ПИ-регулятора. Анализ функционирования АСР с оптимальными настройками.