Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 4:2c93a9f6c9fd, committed 2015-11-28
- Comitter:
- gcorderop
- Date:
- Sat Nov 28 06:46:41 2015 +0000
- Parent:
- 3:2191cc27f1c4
- Commit message:
- final sin push button
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Nov 28 03:17:56 2015 +0000 +++ b/main.cpp Sat Nov 28 06:46:41 2015 +0000 @@ -14,7 +14,7 @@ double t_ant=0; //Inicializacion del tiempo anterior const int total =30000; //double Vt[total]; //Vector de tiempos de eventos -int k = 1; //Indice de los eventos ocurridos +//int k = 1; //Indice de los eventos ocurridos float Tf=1000; //Tiempo m�ximo de simulaci�n int C_Q1=0; //Log de N�mero de paquetes en la cola Q1 @@ -25,15 +25,15 @@ double t_out1=0; //Tiempo de salida de la cola Q1 double t_out2=0; //Tiempo de salida de la cola Q2 double t_out3=0; //Tiempo de salida de la cola Q3 -double t_min=10000; //Variable auxiliar +double t_min=10000; //Variable auxiliar int mini=100; //Variable auxiliar double evalmin[4]; -double a=1103515245; -double m=4294967295; -int c=12345; -double x=10; +double a=16807.0; +double m=2147483646.0; +int c=0; +double x=72841.0; //semilla, cualquier numero entre 0 y m double u=x/m; int suma1 = 0; @@ -43,7 +43,13 @@ double mean1 = 0; double mean2 = 0; double mean3 = 0; -double meanT = 0; +double meanT = 0; + +double uti1 = 0; +double uti2 = 0; +double uti3 = 0; + + // RANDOM double r_unif(void) @@ -91,12 +97,12 @@ evalmin[3]= t_out3; t_min=100; for (int i=0; i<4; i++ ) { - if(t_min > evalmin[i]) { + if (t_min > evalmin[i]) { t_min= evalmin[i]; mini=i; } } - + // Se actualiza el vector de tiempos t_ant=t; t=t+t_min; @@ -162,14 +168,36 @@ mean1=(mean1*t_ant+C_Q1*(t-t_ant))/t; mean2=(mean2*t_ant+C_Q2*(t-t_ant))/t; mean3=(mean3*t_ant+C_Q3*(t-t_ant))/t; + + if (C_Q1==0) { + uti1 = uti1 + (t-t_ant); + } + if (C_Q2==0) { + uti2 = uti2 + (t-t_ant); + } + if (C_Q3==0) { + uti3 = uti3 + (t-t_ant); + } + } //mean2=suma2/total; //mean3=suma3/total; - //meanT = mean1+mean2+mean3; + meanT = mean1+mean2+mean3; + uti1 = 1-uti1/t; + uti2 = 1-uti2/t; + uti3 = 1-uti3/t; + pc.printf("Media Cola 1: %f \r\n",mean1); pc.printf("Media Cola 2: %f \r\n",mean2); - pc.printf("Media Cola 2: %f \r\n",mean3); + pc.printf("Media Cola 3: %f \r\n",mean3); pc.printf("Media Total : %f \r\n",meanT); + pc.printf("Utilizacion Cola 1: %f \r\n",uti1); + pc.printf("Utilizacion Cola 2: %f \r\n",uti2); + pc.printf("Utilizacion Cola 3: %f \r\n",uti3); + pc.printf("Tiempo medio Cola 1: %f \r\n",mean1/(lamb*0.5+mu_q3*S)); + pc.printf("Tiempo medio Cola 2: %f \r\n",mean2/(lamb*0.5)); + pc.printf("Tiempo medio Cola 3: %f \r\n",mean3/(mu_q1+mu_q2)); + pc.printf("Tiempo medio de todo el sistema : %f \r\n",meanT/lamb); }